Make WordPress Core


Ignore:
Timestamp:
12/24/2007 07:01:47 AM (17 years ago)
Author:
westi
Message:

Add documentation for bookmark.php. Fixes #5523 props darkdragon.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/bookmark.php

    r6353 r6480  
    11<?php
    2 
     2/**
     3 * Link/Bookmark API
     4 *
     5 * @package WordPress
     6 * @subpackage Bookmark
     7 */
     8
     9/**
     10 * get_bookmark() - Get Bookmark data based on ID
     11 *
     12 * @since 2.1
     13 * @uses $wpdb Database Object
     14 *
     15 * @param int $bookmark_id
     16 * @param string $output Optional. Either OBJECT, ARRAY_N, or ARRAY_A constant
     17 * @param string $filter Optional, default is 'raw'.
     18 * @return array|object Type returned depends on $output value.
     19 */
    320function get_bookmark($bookmark_id, $output = OBJECT, $filter = 'raw') {
    421    global $wpdb;
     
    2037}
    2138
     39/**
     40 * get_bookmark_field() - Gets single bookmark data item or field.
     41 *
     42 * @since 2.3
     43 * @uses get_bookmark() Gets bookmark object using $bookmark as ID
     44 * @uses sanitize_bookmark_field() Sanitizes Bookmark field based on $context.
     45 *
     46 * @param string $field The name of the data field to return
     47 * @param int $bookmark The bookmark ID to get field
     48 * @param string $context Optional. The context of how the field will be used.
     49 * @return string
     50 */
    2251function get_bookmark_field( $field, $bookmark, $context = 'display' ) {
    2352    $bookmark = (int) $bookmark;
     
    3665}
    3766
    38 // Deprecate
     67/**
     68 * get_link() - Returns bookmark data based on ID.
     69 *
     70 * @since 2.0
     71 * @deprecated Use get_bookmark()
     72 * @see get_bookmark()
     73 *
     74 * @param int $bookmark_id ID of link
     75 * @param string $output Either OBJECT, ARRAY_N, or ARRAY_A
     76 * @return object|array
     77 */
    3978function get_link($bookmark_id, $output = OBJECT) {
    4079    return get_bookmark($bookmark_id, $output);
    4180}
    4281
     82/**
     83 * get_bookmarks() - Retrieves the list of bookmarks
     84 *
     85 * Attempts to retrieve from the cache first based on MD5 hash of arguments. If
     86 * that fails, then the query will be built from the arguments and executed. The
     87 * results will be stored to the cache.
     88 *
     89 * List of default arguments are as follows:
     90 * 'orderby' - Default is 'name' (string). How to order the links by. String is based off of the bookmark scheme.
     91 * 'order' - Default is 'ASC' (string). Either 'ASC' or 'DESC'. Orders in either ascending or descending order.
     92 * 'limit' - Default is -1 (integer) or show all. The amount of bookmarks to display.
     93 * 'category' - Default is empty string (string). Include the links in what category ID(s).
     94 * 'category_name' - Default is empty string (string). Get links by category name.
     95 * 'hide_invisible' - Default is 1 (integer). Whether to show (default) or hide links marked as 'invisible'.
     96 * 'show_updated' - Default is 0 (integer). Will show the time of when the bookmark was last updated.
     97 * 'include' - Default is empty string (string). Include other categories separated by commas.
     98 * 'exclude' - Default is empty string (string). Exclude other categories separated by commas.
     99 *
     100 * @since 2.1
     101 * @uses $wpdb Database Object
     102 *
     103 * @param string|array $args List of arguments to overwrite the defaults
     104 * @return array List of bookmark row objects
     105 */
    43106function get_bookmarks($args = '') {
    44107    global $wpdb;
     
    62125    $inclusions = '';
    63126    if ( !empty($include) ) {
    64     $exclude = '';  //ignore exclude, category, and category_name params if using include
    65     $category = '';
    66     $category_name = '';
     127        $exclude = '';  //ignore exclude, category, and category_name params if using include
     128        $category = '';
     129        $category_name = '';
    67130        $inclinks = preg_split('/[\s,]+/',$include);
    68131        if ( count($inclinks) ) {
     
    160223}
    161224
     225/**
     226 * sanitize_bookmark() - Sanitizes all bookmark fields
     227 *
     228 * @since 2.3
     229 *
     230 * @param object|array $bookmark Bookmark row
     231 * @param string $context Optional, default is 'display'. How to filter the fields
     232 * @return object|array Same type as $bookmark but with fields sanitized.
     233 */
    162234function sanitize_bookmark($bookmark, $context = 'display') {
    163235    $fields = array('link_id', 'link_url', 'link_name', 'link_image', 'link_target', 'link_category',
     
    179251}
    180252
     253/**
     254 * sanitize_bookmark_field() - Sanitizes a bookmark field
     255 *
     256 * Sanitizes the bookmark fields based on what the field name is. If the field has a
     257 * strict value set, then it will be tested for that, else a more generic filtering is
     258 * applied. After the more strict filter is applied, if the $context is 'raw' then the
     259 * value is immediately return.
     260 *
     261 * Hooks exist for the more generic cases. With the 'edit' context, the 'edit_$field'
     262 * filter will be called and passed the $value and $bookmark_id respectively. With the
     263 * 'db' context, the 'pre_$field' filter is called and passed the value. The 'display'
     264 * context is the final context and has the $field has the filter name and is passed the
     265 * $value, $bookmark_id, and $context respectively.
     266 *
     267 * @since 2.3
     268 *
     269 * @param string $field The bookmark field
     270 * @param mixed $value The bookmark field value
     271 * @param int $bookmark_id Bookmark ID
     272 * @param string $context How to filter the field value. Either 'raw', 'edit', 'attribute', 'js', 'db', or 'display'
     273 * @return mixed The filtered value
     274 */
    181275function sanitize_bookmark_field($field, $value, $bookmark_id, $context) {
    182276    $int_fields = array('link_id', 'link_rating');
     
    221315}
    222316
     317/**
     318 * delete_get_bookmark_cache() - Deletes entire bookmark cache
     319 *
     320 * @since 2.1
     321 * @uses wp_cache_delete() Deletes the contents of 'get_bookmarks'
     322 */
    223323function delete_get_bookmark_cache() {
    224324    wp_cache_delete( 'get_bookmarks', 'bookmark' );
Note: See TracChangeset for help on using the changeset viewer.