/** * Return lightbox content for a link */ function bp_links_ajax_link_lightbox() { global $bp; if (!empty($_POST['link_id']) && is_numeric($_POST['link_id'])) { $link = new BP_Links_Link((int) $_POST['link_id']); if ($link instanceof BP_Links_Link && $link->embed() instanceof BP_Links_Embed_Has_Html) { bp_links_ajax_response_string(1, $link->embed()->html()); } } bp_links_ajax_response_string(-1, __('Invalid request', 'buddypress-links')); }
function bp_links_template($args = array()) { // init args used in this scope $type = null; $page = null; $per_page = null; $max = null; $slug = null; $avatar_size = null; // handle query string overrides if (isset($_REQUEST['lpage'])) { $args['page'] = intval($_REQUEST['lpage']); } if (isset($_REQUEST['num'])) { $args['per_page'] = intval($_REQUEST['num']); } // extract 'em extract($args); // handle empty type if (empty($type)) { // get order options $order_options = bp_links_get_order_options(); // default type is first key $type = key($order_options); } // set avatar size $this->avatar_display_size($avatar_size); // set paging props $this->pag_page = $page; $this->pag_num = $per_page; switch ($type) { default: case 'active': $this->links = bp_links_get_active($args); break; case 'newest': $this->links = bp_links_get_newest($args); break; case 'search': $this->links = bp_links_get_search($args); break; case 'popular': $this->links = bp_links_get_popular($args); break; case 'most-votes': $this->links = bp_links_get_most_votes($args); break; case 'high-votes': $this->links = bp_links_get_high_votes($args); break; case 'all': $this->links = bp_links_get_all($args); break; case 'random': $this->links = bp_links_get_random(); break; case 'single-link': $link = new stdClass(); $link->link_id = BP_Links_Link::get_id_from_slug($slug); $this->links = array($link); break; } if ('single-link' == $type) { $this->total_link_count = 1; $this->link_count = 1; } else { if (!$max || $max >= (int) $this->links['total']) { $this->total_link_count = (int) $this->links['total']; } else { $this->total_link_count = (int) $max; } $this->links = $this->links['links']; if ($max) { if ($max >= count($this->links)) { $this->link_count = count($this->links); } else { $this->link_count = (int) $max; } } else { $this->link_count = count($this->links); } } $this->pag_links = paginate_links(array('base' => add_query_arg(array('lpage' => '%#%', 'num' => $this->pag_num, 's' => $_REQUEST['s'], 'sortby' => $this->sort_by, 'order' => $this->order)), 'format' => '', 'total' => ceil($this->total_link_count / $this->pag_num), 'current' => $this->pag_page, 'prev_text' => '«', 'next_text' => '»', 'mid_size' => 1)); }
function bp_links_embed_handle_crop(BP_Links_Link $link) { $link->embed_status_set_enabled(true); }
function bp_links_remove_data_for_user($user_id) { // remove all links for deleted user BP_Links_Link::delete_all_for_user($user_id); do_action('bp_links_remove_data_for_user', $user_id); }