本文整理汇总了PHP中get_bookmarks函数的典型用法代码示例。如果您正苦于以下问题:PHP get_bookmarks函数的具体用法?PHP get_bookmarks怎么用?PHP get_bookmarks使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_bookmarks函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: widget
/**
* Front-end display of widget.
*
* @see WP_Widget::widget()
*
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/
public function widget($args, $instance)
{
extract($args);
$title = apply_filters('widget_title', $instance['title']);
$text = $instance['text'];
$category_id = !empty($instance['category_id']) ? $instance['category_id'] : '';
echo $before_widget;
if (!empty($title)) {
echo $before_title . $title . $after_title;
}
$args = array('category' => $category_id);
$bookmarks = get_bookmarks($args);
echo '<div class="widget-content-link">';
echo '<select onchange="openUrl(this.value)" style="height:35px;">';
echo '<option value=""> Chọn liên kết </option>';
foreach ($bookmarks as $bookmark) {
echo '<option value="', $bookmark->link_url, '">', $bookmark->link_name, '</a><br />';
}
echo '</select>';
echo '</div>';
echo $after_widget;
add_action('wp_footer', 'addJs_LinkCombobox_Widget');
function addJs_LinkCombobox_Widget()
{
echo '<script language="javascript">';
echo 'function openUrl(url){
if(url.length) window.open(url);
}
</script>';
}
}
示例2: mf_sponsor_carousel
/**
* Sponsor Functions
*/
function mf_sponsor_carousel($category_name)
{
// Get all of the sponsor from the links
$sponsors = get_bookmarks(array('orderby' => 'rating', 'category_name' => $category_name));
// Split them into chucks of two
$sponsors = array_chunk($sponsors, 2, true);
// Get the output started.
$output = '<div id="myCarousel" class="carousel slide">';
$output .= '<div class="carousel-inner">';
// Loop through each block of sponsors
foreach ($sponsors as $idx => $sponsor) {
if ($idx == 0) {
$output .= '<div class="item active">';
} else {
$output .= '<div class="item">';
}
$output .= '<div class="row-fluid">';
// Loop through the individual sponsors
foreach ($sponsor as $spon) {
$output .= '<div class="span6"><div class="thumb"><a href="' . esc_url($spon->link_url) . '"><img src="' . wpcom_vip_get_resized_remote_image_url($spon->link_image, 125, 105) . '" alt="' . esc_attr($spon->link_name) . '"></a></div></div>';
}
$output .= '</div></div>';
}
$output .= '</div></div>';
return $output;
}
示例3: updates_requested
function updates_requested()
{
if (isset($_POST['update']) or isset($_POST['action']) or isset($_POST['update_uri'])) {
// Only do things with side-effects for HTTP POST or command line
$fwp_update_invoke = 'post';
} else {
$fwp_update_invoke = 'get';
}
$update_set = array();
if ($fwp_update_invoke != 'get') {
if (isset($_POST['link_ids']) and is_array($_POST['link_ids']) and $_POST['action'] == FWP_UPDATE_CHECKED) {
$targets = get_bookmarks(array('include' => implode(",", $_POST['link_ids'])));
if (is_array($targets)) {
foreach ($targets as $target) {
$update_set[] = $target->link_rss;
}
} else {
// This should never happen
FeedWordPress::critical_bug('fwp_syndication_manage_page::targets', $targets, __LINE__);
}
} elseif (isset($_POST['update_uri'])) {
$targets = $_POST['update_uri'];
if (!is_array($targets)) {
$targets = array($targets);
}
$update_set = $targets;
}
}
return $update_set;
}
示例4: mf_sponsor_list
function mf_sponsor_list($category_name, $slug = '')
{
//get the list of links based on faire name
$sponsors = get_bookmarks(array('orderby' => 'name', 'category_name' => $category_name, 'limit' => 40));
$slugData = get_term_by('slug', $slug, 'link_category', OBJECT);
if (is_object($slugData)) {
$slugCat = get_objects_in_term($slugData->term_id, 'link_category');
} else {
$slugCat = array();
}
//get the list of links based on sponsor category name
$slugData = get_term_by('slug', $category_name, 'link_category', OBJECT);
$sponsorName = get_objects_in_term($slugData->term_id, 'link_category');
//find the links that are in both the sponsor category and specified faire
if (!empty($slugCat)) {
$category = array_intersect($slugCat, $sponsorName);
} else {
$category = $sponsorName;
}
$include = implode(',', $category);
$sponsors = array();
if (!empty($include)) {
$sponsors = get_bookmarks(array('orderby' => 'name', 'limit' => 40, 'include' => $include));
}
// Get the output started.
$output = '<ul>';
// Loop through each block of sponsors
foreach ($sponsors as $idx => $spon) {
//foreach ($sponsor as $spon) {
$output .= '<li><a href="' . esc_url($spon->link_url) . '"><img src="' . legacy_get_resized_remote_image_url($spon->link_image, 125, 105) . '" alt=""></a></li>';
//}
}
$output .= '</ul>';
return $output;
}
示例5: displayLinks
function displayLinks($cat, $class = 'boxesBox', $close = '', $limit = 10)
{
//get the links and store it in an array
$b = get_bookmarks('category=' . $cat . '&orderby=id&order=DESC&limit=' . $limit);
$html .= '<div class="' . $class . '"><h2 class="blue">Link</h2>';
$html .= '<div class="boxes BoxesSecond BoxesSecondBrowserFix boxFullWidth">';
// column left
$html .= '<ul class="ulLinkLeft">';
for ($i = 0; $i < 5; $i++) {
$html .= '<li>';
$html .= '<a href="' . $b[$i]->link_url . '" title="' . $b[$i]->link_name . '" target="_blank">' . $b[$i]->link_name . '</a>';
$html .= '</li>';
}
$html .= '</ul>';
$html .= '<ul>';
//column right
for ($i = 5; $i < 10; $i++) {
$html .= '<li>';
$html .= '<a href="' . $b[$i]->link_url . '" title="' . $b[$i]->link_name . '" target="_blank">' . $b[$i]->link_name . '</a>';
$html .= '</li>';
}
$html .= '</ul>';
$html .= '<p class="segnala2"><a href="http://dito.areato.org/home/?page_id=124" class="segnala">Tutti i link</a></p>';
$html .= '</div></div>' . $close;
echo $html;
}
示例6: widget
function widget($args, $instance)
{
$data['title'] = apply_filters('widget_title', empty($instance['title']) ? __('Links') : $instance['title'], $instance, $this->id_base);
$category = isset($instance['category']) ? $instance['category'] : false;
// load bookmarks
$data['links'] = get_bookmarks(array('orderby' => 'name', 'order' => 'ASC', 'category_name' => $category));
$this->display($instance, $data);
}
示例7: widget
/** @see WP_Widget::widget */
function widget($args, $instance)
{
extract($args);
$title = apply_filters('widget_title', $instance['title']);
$link = apply_filters('widget_link', $instance['link']);
//Operation with TITLE and LINK
if ('' . $link == '') {
$link = "#";
$target = "_self";
} else {
$target = "_blank";
}
if ('' . $title == '') {
$html_title = "";
} else {
$first = substr($title, 0, 1);
$other = substr($title, 1);
$html_title = '<div class="widget_title">';
$html_title .= '<a href="' . $link . '" target="' . $target . '">';
$html_title .= $before_title;
$html_title .= '<span class="widget_title_first">' . $first . '</span>';
$html_title .= $other;
$html_title .= $after_title;
$html_title .= "</a>";
$html_title .= "</div>";
$html_title .= '<div class="widget_sep"></div>';
}
$args = array('category_name' => "blogroll", 'hide_invisible' => 1, 'show_updated' => 0, 'echo' => 1, 'categorize' => 0, 'category_orderby' => 'name', 'category_order' => 'ASC', 'class' => '');
?>
<?php
echo $before_widget;
?>
<div class="widget">
<?php
echo $html_title;
?>
<div class="widget_content blogroll_list">
<?php
$global = get_bookmarks($args);
foreach ($global as $bm) {
$html = "<div class='blogroll_el'> - <a href='" . $bm->link_url . "' target='" . $bm->link_target . "'>" . $bm->link_name . "</a></div>";
print $html;
}
?>
</div>
</div>
<?php
echo $after_widget;
?>
<?php
}
示例8: acegiak_atlink_content
function acegiak_atlink_content($content)
{
return preg_replace_callback('`(^|\\W)@(\\w+)`i', function ($matches) {
foreach (get_bookmarks() as $bookmark) {
if (preg_match("`" . $matches[2] . "`i", preg_replace("`\\W`", "", $bookmark->link_name))) {
return $matches[1] . '<a class="h-card u-category" href="' . $bookmark->link_url . '" alt="' . $bookmark->link_name . '">' . $bookmark->link_name . '</a>';
}
}
return $matches[1] . '<a class="h-card u-category" href="https://twitter.com/' . $matches[2] . '" alt="@' . $matches[2] . '">@' . $matches[2] . '</a>';
}, $content);
}
示例9: test_orderby_rand_should_not_be_cached
/**
* @ticket 18356
*/
public function test_orderby_rand_should_not_be_cached()
{
global $wpdb;
$bookmarks = self::factory()->bookmark->create_many(2);
$found1 = get_bookmarks(array('orderby' => 'rand'));
$num_queries = $wpdb->num_queries;
$found2 = get_bookmarks(array('orderby' => 'rand'));
// equal sets != same order
$this->assertEqualSets($found1, $found2);
$this->assertTrue($num_queries < $wpdb->num_queries);
}
示例10: link_delete
/**
* Deletes plugin link from Blogroll
*
* @return void
*/
public static function link_delete()
{
require_once ABSPATH . 'wp-admin/includes/bookmark.php';
$bookmarks = get_bookmarks();
$link_id = 0;
foreach ($bookmarks as $bookmark) {
if ($bookmark->link_url == W3TC_LINK_URL) {
wp_delete_link($bookmark->link_id);
}
}
}
示例11: ubik_links
function ubik_links()
{
// Initialize
$links = $category = $search = '';
$links_array = array();
// Private links can only be seen by users with the manage_links capability
$hide_invisible = current_user_can('manage_links') ? 0 : 1;
// Get the link category from the query string
if (get_query_var('link_category')) {
$category = get_query_var('link_category');
}
// Link search; also works with categories
if (get_query_var('link_search')) {
$search = get_query_var('link_search');
}
// Fetch the bookmarks
$links = get_bookmarks(array('orderby' => apply_filters('ubik_links_orderby', 'link_id'), 'order' => apply_filters('ubik_links_order', 'DESC'), 'category_name' => $category, 'hide_invisible' => $hide_invisible, 'search' => esc_sql($search), 'limit' => -1));
// Check for results then run through the loop
if (!empty($links)) {
foreach ($links as $link) {
// Initialize all variables
$title = $desc = $url = $rel = $target = $updated = $cats = $cats_formatted = '';
// Conditionally set relevant variables
if (!empty($link->link_id)) {
$id = $link->link_id;
}
if (!empty($link->link_name)) {
$title = $link->link_name;
}
if (!empty($link->link_description)) {
$desc = $link->link_description;
}
if (!empty($link->link_url)) {
$url = $link->link_url;
$domain = parse_url($url);
$domain = $domain['host'];
}
if (!empty($link->link_rel)) {
$rel = ' rel="' . $link->link_rel . '"';
}
if (!empty($link->link_target)) {
$target = ' target="' . $link->link_target . '"';
}
// Link categories
if (!empty($id)) {
$cats = ubik_links_categories($id);
}
// Assemble the links array; this returns the raw data as well as processed strings
$links_array[] = array('id' => $id, 'title' => $title, 'description' => $desc, 'url' => $url, 'domain' => $domain, 'rel' => $rel, 'target' => $target, 'cats' => $cats, 'cats_html' => implode(', ', $cats), 'cats_list' => ubik_links_categories_list($cats), 'link' => '<a href="' . $url . '"' . $rel . $target . '>' . $title . '</a>');
}
}
return apply_filters('ubik_links', $links_array);
}
示例12: xv_bookmarks
function xv_bookmarks()
{
$bookmarks = get_bookmarks('orderby=name&show_description=1');
foreach ($bookmarks as $bookmark) {
echo '<li><a href="' . $bookmark->link_url . '">';
if (substr($bookmark->link_image, 0, 4) == 'http') {
echo '<span class="imgfavicon"><img src="' . $bookmark->link_image . '" alt="' . $bookmark->link_name . '" /></span>';
}
echo $bookmark->link_name . '</a><div class="antifloat"></div>';
echo '</li>';
}
}
示例13: link_exists
function link_exists($link_url)
{
$bookmarks = get_bookmarks();
$matching_id = 0;
foreach ($bookmarks as $bookmark) {
if ($bookmark->link_url == $link_url) {
$matching_id = $bookmark->link_id;
break;
}
}
return $matching_id;
}
示例14: get_footer_link_options
function get_footer_link_options()
{
$links = get_bookmarks(array('category_name' => 'Dynamic'));
if (!empty($links)) {
$options = array();
foreach ($links as $link) {
$options[$link->link_id] = $link->link_name;
}
return $options;
} else {
return array();
}
}
示例15: show_nav
function show_nav($nav_id = 'nav', $css_class = 'nav', $before_html = '', $after_html = '', $seperator = '', $display_as_list = false)
{
if ($display_as_list) {
$containertag = "ul";
$openlist = "<li>";
$closelist = "</li>";
} else {
$containertag = "div";
$openlist = "";
$closelist = "";
}
$useseperator = $seperator;
echo '<' . $containertag . ' id="' . $nav_id . '" class="' . $css_class . '">';
$navlinks = get_bookmarks('orderby=rating&category_name=' . $nav_id);
$numOfItems = count($navlinks);
$counter = 0;
foreach ((array) $navlinks as $navlink) {
$counter += 1;
if ($counter == $numOfItems) {
$useseperator = "";
}
if (!empty($navlink->link_url)) {
$link_url = $navlink->link_url;
} else {
$link_url = "";
}
if (!empty($navlink->link_name)) {
$link_name = $navlink->link_name;
} else {
$link_name = "";
}
if (!empty($navlink->link_description)) {
$link_description = ' title="' . $navlink->link_description . '"';
} else {
$link_description = "";
}
if (!empty($navlink->link_target)) {
$link_target = ' target="' . $navlink->link_target . '"';
} else {
$link_target = "";
}
$markCurrent = '';
$rootpath_ar = explode("/", $_SERVER['REQUEST_URI']);
$rootpath = "/" . $rootpath_ar[1] . "/";
if ($link_url == $_SERVER['REQUEST_URI'] || $link_url . "/" == $_SERVER['REQUEST_URI'] || $link_url == $_SERVER['REQUEST_URI'] . "/" || $link_url == $rootpath) {
$markCurrent = ' class="current"';
}
echo $openlist . '<a href="' . $link_url . '"' . $link_description . $link_target . $markCurrent . '>' . $before_html . $link_name . $after_html . "</a>" . $closelist . $useseperator . "\n";
}
echo "</{$containertag}>\n";
}