-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblogroll-in-posts.php
89 lines (76 loc) · 2.21 KB
/
blogroll-in-posts.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/*
Plugin Name: Blogroll In Posts
Plugin URI: http://www.coolryan.com/plugins/blogroll-in-posts
Description: Put your favorite links easily into your posts
Version: 1.1
Author: Cool Ryan
Author URI: http://www.coolryan.com/
*/
function bip_shortcode($atts) {
extract(shortcode_atts(array(
'orderby' => 'name',
'order' => 'ASC',
'limit' => -1,
'category' => null,
'category_name' => null,
'hide_invisible' => 1,
'show_updated' => 0,
'include' => null,
'exclude' => null,
'search' => null,
'show_category' => 0,
'title' => null, // The title of the blogroll, if empty, none is shown
'show_in_list' => 1, // whether or not to show in list format or <p> format.
'show_description' => 1, // Whether or not to show the description
'show_rating' => 0 // Wether or not to show the rating
),$atts));
$args = array(
'orderby' => $orderby,
'order' => $order,
'limit' => $limit,
'category' => $category,
'category_name' => $category_name,
'hide_invisible' => $hide_invisible,
'show_updated' => $show_updated,
'include' => $include,
'exclude' => $exclude,
'search' => $search);
$bookmarks = get_bookmarks($args);
$blogroll = '';
/** Show title */
if(!empty($title)) {
$blogroll .= '<h2>'.$title.'</h2>';
}
if($show_in_list == 1) {
$before_link = '<li>';
$after_link = '</li>';
$before_list = '<ul>';
$after_list = '</ul>';
$between = ' - ';
}
else {
$before_link = '<p>';
$after_link = '</p>';
$before_list = '';
$after_list = '';
$between = '<br />';
}
$blogroll .= $before_list;
foreach($bookmarks as $b) {
$blogroll .= $before_link.'<a id="'.$b->link_id.'" href="'.$b->link_url.'" target="'.$b->link_target.'">'.$b->link_name.'</a>';
/** Show description */
if($show_description == 1) {
$blogroll .= $between.$b->link_description;
}
/** Show rating */
if($show_rating == 1) {
$blogroll .= $between.'Rating: '.$b->link_rating.'/10';
}
$blogroll .= $after_link;
}
$blogroll .= $after_list;
return $blogroll;
}
add_shortcode('blogroll', 'bip_shortcode');
?>