sanitize_bookmark() – Sanitizes all bookmark fields

You appear to be a bot. Output may be restricted

Description

Sanitizes all bookmark fields.

Usage

$stdClass|array = sanitize_bookmark( $bookmark, $context );

Parameters

$bookmark
( stdClass|array ) required – Bookmark row.
$context
( string ) optional default: display – Optional. How to filter the fields. Default 'display'.

Returns

stdClass|array Same type as $bookmark but with fields sanitized.

Source

File name: wordpress/wp-includes/bookmark.php
Lines:

1 to 40 of 40
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;
}
 

 View on GitHub View on Trac