get_bookmark

The timeline below displays how wordpress function get_bookmark has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.5

/**
 * Link/Bookmark API
 *
 * @package WordPress
 * @subpackage Bookmark
 */
/**
 * Retrieves bookmark data.
 *
 * @since 2.1.0
 *
 * @global object $link Current link object.
 * @global wpdb   $wpdb WordPress database abstraction object.
 *
 * @param int|stdClass $bookmark
 * @param string       $output   Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which
 *                               correspond to an stdClass object, an associative array, or a numeric array,
 *                               respectively. Default OBJECT.
 * @param string       $filter   Optional. How to sanitize bookmark fields. Default 'raw'.
 * @return array|object|null Type returned depends on $output value.
 */
function get_bookmark($bookmark, $output = OBJECT, $filter = 'raw')
{
    global $wpdb;
    if (empty($bookmark)) {
        if (isset($GLOBALS['link'])) {
            $_bookmark =& $GLOBALS['link'];
        } else {
            $_bookmark = null;
        }
    } elseif (is_object($bookmark)) {
        wp_cache_add($bookmark->link_id, $bookmark, 'bookmark');
        $_bookmark = $bookmark;
    } else if (isset($GLOBALS['link']) && $GLOBALS['link']->link_id == $bookmark) {
        $_bookmark =& $GLOBALS['link'];
    } else {
        $_bookmark = wp_cache_get($bookmark, 'bookmark');
        if (!$_bookmark) {
            $_bookmark = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->links} WHERE link_id = %d LIMIT 1", $bookmark));
            if ($_bookmark) {
                $_bookmark->link_category = array_unique(wp_get_object_terms($_bookmark->link_id, 'link_category', array('fields' => 'ids')));
                wp_cache_add($_bookmark->link_id, $_bookmark, 'bookmark');
            }
        }
    }
    if (!$_bookmark) {
        return $_bookmark;
    }
    $_bookmark = sanitize_bookmark($_bookmark, $filter);
    if (OBJECT === $output) {
        return $_bookmark;
    } elseif (ARRAY_A === $output) {
        return get_object_vars($_bookmark);
    } elseif (ARRAY_N === $output) {
        return array_values(get_object_vars($_bookmark));
    } else {
        return $_bookmark;
    }
}

WordPress Version: 6.1

/**
 * Link/Bookmark API
 *
 * @package WordPress
 * @subpackage Bookmark
 */
/**
 * Retrieves bookmark data.
 *
 * @since 2.1.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|stdClass $bookmark
 * @param string       $output   Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which
 *                               correspond to an stdClass object, an associative array, or a numeric array,
 *                               respectively. Default OBJECT.
 * @param string       $filter   Optional. How to sanitize bookmark fields. Default 'raw'.
 * @return array|object|null Type returned depends on $output value.
 */
function get_bookmark($bookmark, $output = OBJECT, $filter = 'raw')
{
    global $wpdb;
    if (empty($bookmark)) {
        if (isset($GLOBALS['link'])) {
            $_bookmark =& $GLOBALS['link'];
        } else {
            $_bookmark = null;
        }
    } elseif (is_object($bookmark)) {
        wp_cache_add($bookmark->link_id, $bookmark, 'bookmark');
        $_bookmark = $bookmark;
    } else if (isset($GLOBALS['link']) && $GLOBALS['link']->link_id == $bookmark) {
        $_bookmark =& $GLOBALS['link'];
    } else {
        $_bookmark = wp_cache_get($bookmark, 'bookmark');
        if (!$_bookmark) {
            $_bookmark = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->links} WHERE link_id = %d LIMIT 1", $bookmark));
            if ($_bookmark) {
                $_bookmark->link_category = array_unique(wp_get_object_terms($_bookmark->link_id, 'link_category', array('fields' => 'ids')));
                wp_cache_add($_bookmark->link_id, $_bookmark, 'bookmark');
            }
        }
    }
    if (!$_bookmark) {
        return $_bookmark;
    }
    $_bookmark = sanitize_bookmark($_bookmark, $filter);
    if (OBJECT === $output) {
        return $_bookmark;
    } elseif (ARRAY_A === $output) {
        return get_object_vars($_bookmark);
    } elseif (ARRAY_N === $output) {
        return array_values(get_object_vars($_bookmark));
    } else {
        return $_bookmark;
    }
}

WordPress Version: 5.8

/**
 * Link/Bookmark API
 *
 * @package WordPress
 * @subpackage Bookmark
 */
/**
 * Retrieve Bookmark data
 *
 * @since 2.1.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|stdClass $bookmark
 * @param string       $output   Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which
 *                               correspond to an stdClass object, an associative array, or a numeric array,
 *                               respectively. Default OBJECT.
 * @param string       $filter   Optional. How to sanitize bookmark fields. Default 'raw'.
 * @return array|object|null Type returned depends on $output value.
 */
function get_bookmark($bookmark, $output = OBJECT, $filter = 'raw')
{
    global $wpdb;
    if (empty($bookmark)) {
        if (isset($GLOBALS['link'])) {
            $_bookmark =& $GLOBALS['link'];
        } else {
            $_bookmark = null;
        }
    } elseif (is_object($bookmark)) {
        wp_cache_add($bookmark->link_id, $bookmark, 'bookmark');
        $_bookmark = $bookmark;
    } else if (isset($GLOBALS['link']) && $GLOBALS['link']->link_id == $bookmark) {
        $_bookmark =& $GLOBALS['link'];
    } else {
        $_bookmark = wp_cache_get($bookmark, 'bookmark');
        if (!$_bookmark) {
            $_bookmark = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->links} WHERE link_id = %d LIMIT 1", $bookmark));
            if ($_bookmark) {
                $_bookmark->link_category = array_unique(wp_get_object_terms($_bookmark->link_id, 'link_category', array('fields' => 'ids')));
                wp_cache_add($_bookmark->link_id, $_bookmark, 'bookmark');
            }
        }
    }
    if (!$_bookmark) {
        return $_bookmark;
    }
    $_bookmark = sanitize_bookmark($_bookmark, $filter);
    if (OBJECT === $output) {
        return $_bookmark;
    } elseif (ARRAY_A === $output) {
        return get_object_vars($_bookmark);
    } elseif (ARRAY_N === $output) {
        return array_values(get_object_vars($_bookmark));
    } else {
        return $_bookmark;
    }
}

WordPress Version: 5.5

/**
 * Link/Bookmark API
 *
 * @package WordPress
 * @subpackage Bookmark
 */
/**
 * Retrieve Bookmark data
 *
 * @since 2.1.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|stdClass $bookmark
 * @param string       $output   Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which
 *                               correspond to an stdClass object, an associative array, or a numeric array,
 *                               respectively. Default OBJECT.
 * @param string       $filter   Optional. How to sanitize bookmark fields. Default 'raw'.
 * @return array|object|null Type returned depends on $output value.
 */
function get_bookmark($bookmark, $output = OBJECT, $filter = 'raw')
{
    global $wpdb;
    if (empty($bookmark)) {
        if (isset($GLOBALS['link'])) {
            $_bookmark =& $GLOBALS['link'];
        } else {
            $_bookmark = null;
        }
    } elseif (is_object($bookmark)) {
        wp_cache_add($bookmark->link_id, $bookmark, 'bookmark');
        $_bookmark = $bookmark;
    } else if (isset($GLOBALS['link']) && $GLOBALS['link']->link_id == $bookmark) {
        $_bookmark =& $GLOBALS['link'];
    } else {
        $_bookmark = wp_cache_get($bookmark, 'bookmark');
        if (!$_bookmark) {
            $_bookmark = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->links} WHERE link_id = %d LIMIT 1", $bookmark));
            if ($_bookmark) {
                $_bookmark->link_category = array_unique(wp_get_object_terms($_bookmark->link_id, 'link_category', array('fields' => 'ids')));
                wp_cache_add($_bookmark->link_id, $_bookmark, 'bookmark');
            }
        }
    }
    if (!$_bookmark) {
        return $_bookmark;
    }
    $_bookmark = sanitize_bookmark($_bookmark, $filter);
    if (OBJECT == $output) {
        return $_bookmark;
    } elseif (ARRAY_A == $output) {
        return get_object_vars($_bookmark);
    } elseif (ARRAY_N == $output) {
        return array_values(get_object_vars($_bookmark));
    } else {
        return $_bookmark;
    }
}

WordPress Version: 5.4

/**
 * Link/Bookmark API
 *
 * @package WordPress
 * @subpackage Bookmark
 */
/**
 * Retrieve Bookmark data
 *
 * @since 2.1.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|stdClass $bookmark
 * @param string $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which correspond to
 *                       an stdClass object, an associative array, or a numeric array, respectively. Default OBJECT.
 * @param string $filter Optional, default is 'raw'.
 * @return array|object|null Type returned depends on $output value.
 */
function get_bookmark($bookmark, $output = OBJECT, $filter = 'raw')
{
    global $wpdb;
    if (empty($bookmark)) {
        if (isset($GLOBALS['link'])) {
            $_bookmark =& $GLOBALS['link'];
        } else {
            $_bookmark = null;
        }
    } elseif (is_object($bookmark)) {
        wp_cache_add($bookmark->link_id, $bookmark, 'bookmark');
        $_bookmark = $bookmark;
    } else if (isset($GLOBALS['link']) && $GLOBALS['link']->link_id == $bookmark) {
        $_bookmark =& $GLOBALS['link'];
    } else {
        $_bookmark = wp_cache_get($bookmark, 'bookmark');
        if (!$_bookmark) {
            $_bookmark = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->links} WHERE link_id = %d LIMIT 1", $bookmark));
            if ($_bookmark) {
                $_bookmark->link_category = array_unique(wp_get_object_terms($_bookmark->link_id, 'link_category', array('fields' => 'ids')));
                wp_cache_add($_bookmark->link_id, $_bookmark, 'bookmark');
            }
        }
    }
    if (!$_bookmark) {
        return $_bookmark;
    }
    $_bookmark = sanitize_bookmark($_bookmark, $filter);
    if (OBJECT == $output) {
        return $_bookmark;
    } elseif (ARRAY_A == $output) {
        return get_object_vars($_bookmark);
    } elseif (ARRAY_N == $output) {
        return array_values(get_object_vars($_bookmark));
    } else {
        return $_bookmark;
    }
}

WordPress Version: 5.3

/**
 * Link/Bookmark API
 *
 * @package WordPress
 * @subpackage Bookmark
 */
/**
 * Retrieve Bookmark data
 *
 * @since 2.1.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|stdClass $bookmark
 * @param string $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which correspond to
 *                       an stdClass object, an associative array, or a numeric array, respectively. Default OBJECT.
 * @param string $filter Optional, default is 'raw'.
 * @return array|object|null Type returned depends on $output value.
 */
function get_bookmark($bookmark, $output = OBJECT, $filter = 'raw')
{
    global $wpdb;
    if (empty($bookmark)) {
        if (isset($GLOBALS['link'])) {
            $_bookmark =& $GLOBALS['link'];
        } else {
            $_bookmark = null;
        }
    } elseif (is_object($bookmark)) {
        wp_cache_add($bookmark->link_id, $bookmark, 'bookmark');
        $_bookmark = $bookmark;
    } else if (isset($GLOBALS['link']) && $GLOBALS['link']->link_id == $bookmark) {
        $_bookmark =& $GLOBALS['link'];
    } else {
        $_bookmark = wp_cache_get($bookmark, 'bookmark');
        if (!$_bookmark) {
            $_bookmark = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->links} WHERE link_id = %d LIMIT 1", $bookmark));
            if ($_bookmark) {
                $_bookmark->link_category = array_unique(wp_get_object_terms($_bookmark->link_id, 'link_category', array('fields' => 'ids')));
                wp_cache_add($_bookmark->link_id, $_bookmark, 'bookmark');
            }
        }
    }
    if (!$_bookmark) {
        return $_bookmark;
    }
    $_bookmark = sanitize_bookmark($_bookmark, $filter);
    if ($output == OBJECT) {
        return $_bookmark;
    } elseif ($output == ARRAY_A) {
        return get_object_vars($_bookmark);
    } elseif ($output == ARRAY_N) {
        return array_values(get_object_vars($_bookmark));
    } else {
        return $_bookmark;
    }
}

WordPress Version: 4.7

/**
 * Link/Bookmark API
 *
 * @package WordPress
 * @subpackage Bookmark
 */
/**
 * Retrieve Bookmark data
 *
 * @since 2.1.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|stdClass $bookmark
 * @param string $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which correspond to
 *                       an stdClass object, an associative array, or a numeric array, respectively. Default OBJECT.
 * @param string $filter Optional, default is 'raw'.
 * @return array|object|null Type returned depends on $output value.
 */
function get_bookmark($bookmark, $output = OBJECT, $filter = 'raw')
{
    global $wpdb;
    if (empty($bookmark)) {
        if (isset($GLOBALS['link'])) {
            $_bookmark =& $GLOBALS['link'];
        } else {
            $_bookmark = null;
        }
    } elseif (is_object($bookmark)) {
        wp_cache_add($bookmark->link_id, $bookmark, 'bookmark');
        $_bookmark = $bookmark;
    } else if (isset($GLOBALS['link']) && $GLOBALS['link']->link_id == $bookmark) {
        $_bookmark =& $GLOBALS['link'];
    } elseif (!$_bookmark = wp_cache_get($bookmark, 'bookmark')) {
        $_bookmark = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->links} WHERE link_id = %d LIMIT 1", $bookmark));
        if ($_bookmark) {
            $_bookmark->link_category = array_unique(wp_get_object_terms($_bookmark->link_id, 'link_category', array('fields' => 'ids')));
            wp_cache_add($_bookmark->link_id, $_bookmark, 'bookmark');
        }
    }
    if (!$_bookmark) {
        return $_bookmark;
    }
    $_bookmark = sanitize_bookmark($_bookmark, $filter);
    if ($output == OBJECT) {
        return $_bookmark;
    } elseif ($output == ARRAY_A) {
        return get_object_vars($_bookmark);
    } elseif ($output == ARRAY_N) {
        return array_values(get_object_vars($_bookmark));
    } else {
        return $_bookmark;
    }
}

WordPress Version: 4.3

/**
 * Link/Bookmark API
 *
 * @package WordPress
 * @subpackage Bookmark
 */
/**
 * Retrieve Bookmark data
 *
 * @since 2.1.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|stdClass $bookmark
 * @param string $output Optional. Either OBJECT, ARRAY_N, or ARRAY_A constant
 * @param string $filter Optional, default is 'raw'.
 * @return array|object|null Type returned depends on $output value.
 */
function get_bookmark($bookmark, $output = OBJECT, $filter = 'raw')
{
    global $wpdb;
    if (empty($bookmark)) {
        if (isset($GLOBALS['link'])) {
            $_bookmark =& $GLOBALS['link'];
        } else {
            $_bookmark = null;
        }
    } elseif (is_object($bookmark)) {
        wp_cache_add($bookmark->link_id, $bookmark, 'bookmark');
        $_bookmark = $bookmark;
    } else if (isset($GLOBALS['link']) && $GLOBALS['link']->link_id == $bookmark) {
        $_bookmark =& $GLOBALS['link'];
    } elseif (!$_bookmark = wp_cache_get($bookmark, 'bookmark')) {
        $_bookmark = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->links} WHERE link_id = %d LIMIT 1", $bookmark));
        if ($_bookmark) {
            $_bookmark->link_category = array_unique(wp_get_object_terms($_bookmark->link_id, 'link_category', array('fields' => 'ids')));
            wp_cache_add($_bookmark->link_id, $_bookmark, 'bookmark');
        }
    }
    if (!$_bookmark) {
        return $_bookmark;
    }
    $_bookmark = sanitize_bookmark($_bookmark, $filter);
    if ($output == OBJECT) {
        return $_bookmark;
    } elseif ($output == ARRAY_A) {
        return get_object_vars($_bookmark);
    } elseif ($output == ARRAY_N) {
        return array_values(get_object_vars($_bookmark));
    } else {
        return $_bookmark;
    }
}

WordPress Version: 4.1

/**
 * Link/Bookmark API
 *
 * @package WordPress
 * @subpackage Bookmark
 */
/**
 * Retrieve Bookmark data
 *
 * @since 2.1.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|stdClass $bookmark
 * @param string $output Optional. Either OBJECT, ARRAY_N, or ARRAY_A constant
 * @param string $filter Optional, default is 'raw'.
 * @return array|object Type returned depends on $output value.
 */
function get_bookmark($bookmark, $output = OBJECT, $filter = 'raw')
{
    global $wpdb;
    if (empty($bookmark)) {
        if (isset($GLOBALS['link'])) {
            $_bookmark =& $GLOBALS['link'];
        } else {
            $_bookmark = null;
        }
    } elseif (is_object($bookmark)) {
        wp_cache_add($bookmark->link_id, $bookmark, 'bookmark');
        $_bookmark = $bookmark;
    } else if (isset($GLOBALS['link']) && $GLOBALS['link']->link_id == $bookmark) {
        $_bookmark =& $GLOBALS['link'];
    } elseif (!$_bookmark = wp_cache_get($bookmark, 'bookmark')) {
        $_bookmark = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->links} WHERE link_id = %d LIMIT 1", $bookmark));
        if ($_bookmark) {
            $_bookmark->link_category = array_unique(wp_get_object_terms($_bookmark->link_id, 'link_category', array('fields' => 'ids')));
            wp_cache_add($_bookmark->link_id, $_bookmark, 'bookmark');
        }
    }
    if (!$_bookmark) {
        return $_bookmark;
    }
    $_bookmark = sanitize_bookmark($_bookmark, $filter);
    if ($output == OBJECT) {
        return $_bookmark;
    } elseif ($output == ARRAY_A) {
        return get_object_vars($_bookmark);
    } elseif ($output == ARRAY_N) {
        return array_values(get_object_vars($_bookmark));
    } else {
        return $_bookmark;
    }
}

WordPress Version: 3.7

/**
 * Link/Bookmark API
 *
 * @package WordPress
 * @subpackage Bookmark
 */
/**
 * Retrieve Bookmark data
 *
 * @since 2.1.0
 * @uses $wpdb Database Object
 *
 * @param mixed $bookmark
 * @param string $output Optional. Either OBJECT, ARRAY_N, or ARRAY_A constant
 * @param string $filter Optional, default is 'raw'.
 * @return array|object Type returned depends on $output value.
 */
function get_bookmark($bookmark, $output = OBJECT, $filter = 'raw')
{
    global $wpdb;
    if (empty($bookmark)) {
        if (isset($GLOBALS['link'])) {
            $_bookmark =& $GLOBALS['link'];
        } else {
            $_bookmark = null;
        }
    } elseif (is_object($bookmark)) {
        wp_cache_add($bookmark->link_id, $bookmark, 'bookmark');
        $_bookmark = $bookmark;
    } else if (isset($GLOBALS['link']) && $GLOBALS['link']->link_id == $bookmark) {
        $_bookmark =& $GLOBALS['link'];
    } elseif (!$_bookmark = wp_cache_get($bookmark, 'bookmark')) {
        $_bookmark = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->links} WHERE link_id = %d LIMIT 1", $bookmark));
        if ($_bookmark) {
            $_bookmark->link_category = array_unique(wp_get_object_terms($_bookmark->link_id, 'link_category', array('fields' => 'ids')));
            wp_cache_add($_bookmark->link_id, $_bookmark, 'bookmark');
        }
    }
    if (!$_bookmark) {
        return $_bookmark;
    }
    $_bookmark = sanitize_bookmark($_bookmark, $filter);
    if ($output == OBJECT) {
        return $_bookmark;
    } elseif ($output == ARRAY_A) {
        return get_object_vars($_bookmark);
    } elseif ($output == ARRAY_N) {
        return array_values(get_object_vars($_bookmark));
    } else {
        return $_bookmark;
    }
}