Skip to content

Instantly share code, notes, and snippets.

@pippinsplugins
Created August 21, 2012 00:36
Show Gist options
  • Select an option

  • Save pippinsplugins/3409911 to your computer and use it in GitHub Desktop.

Select an option

Save pippinsplugins/3409911 to your computer and use it in GitHub Desktop.
// will show a list of a user's bookmarks
function upb_list_bookmarks( $delete_link = true, $delete_text = 'Delete' ) {
if(is_user_logged_in()) {
$display = '<ul class="upb-bookmarks-list">';
$bookmarks = upb_get_user_meta(upb_get_user_id());
if($bookmarks) {
foreach( $bookmarks as $bookmark) {
$bookmark_object = get_post( $bookmark );
$display .= '<li class="upb_bookmark bookmark-' . $bookmark . '">';
$display .= '<a href="' . get_permalink($bookmark) . '" class="upb_bookmark_link" title="' . get_the_title($bookmark) . '">' . get_the_title($bookmark) . '</a>';
if($delete_link) {
$display .= ' - <a href="#" class="upb_del_bookmark upb_del_bookmark_' . $bookmark . '" rel="' . $bookmark . '" title="' . __('Remove this Bookmark') . '">' . $delete_text . '</a>';
}
$display .= '<div class="bookmark_content">' . wpautop( $bookmark_object->post_content ) . '</div>';
$display .= '</li>';
}
} else {
$display .= '<li class="bookmark-link no-bookmarks">You do not have any bookmarked posts.</li>';
}
$display .= '</ul>';
}
else {
$display .= 'You must be logged in to view your bookmarks.';
}
return $display;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment