| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
function get_linksbyname($cat_name = "noname", $before = '', $after = '<br />', |
|---|
| 26 |
$between = " ", $show_images = true, $orderby = 'id', |
|---|
| 27 |
$show_description = true, $show_rating = false, |
|---|
| 28 |
$limit = -1, $show_updated = 0) { |
|---|
| 29 |
global $wpdb; |
|---|
| 30 |
$cat_id = -1; |
|---|
| 31 |
$results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'"); |
|---|
| 32 |
if ($results) { |
|---|
| 33 |
foreach ($results as $result) { |
|---|
| 34 |
$cat_id = $result->cat_id; |
|---|
| 35 |
} |
|---|
| 36 |
} |
|---|
| 37 |
get_links($cat_id, $before, $after, $between, $show_images, $orderby, |
|---|
| 38 |
$show_description, $show_rating, $limit, $show_updated); |
|---|
| 39 |
} |
|---|
| 40 |
|
|---|
| 41 |
function bool_from_yn($yn) { |
|---|
| 42 |
if ($yn == 'Y') return 1; |
|---|
| 43 |
return 0; |
|---|
| 44 |
} |
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
function wp_get_linksbyname($category, $args = '') { |
|---|
| 52 |
global $wpdb; |
|---|
| 53 |
|
|---|
| 54 |
$cat = $wpdb->get_row("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, " |
|---|
| 55 |
. " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, " |
|---|
| 56 |
. " text_after_all, list_limit FROM $wpdb->linkcategories WHERE cat_name='$category'"); |
|---|
| 57 |
|
|---|
| 58 |
if (! $cat) { |
|---|
| 59 |
return; |
|---|
| 60 |
} |
|---|
| 61 |
|
|---|
| 62 |
if (empty($args)) { |
|---|
| 63 |
if ($cat->sort_desc == 'Y') { |
|---|
| 64 |
$cat->sort_order = '_'.$cat->sort_order; |
|---|
| 65 |
} |
|---|
| 66 |
get_links($cat->cat_id, $cat->text_before_link, $cat->text_after_all, |
|---|
| 67 |
$cat->text_after_link, bool_from_yn($cat->show_images), $cat->sort_order, |
|---|
| 68 |
bool_from_yn($cat->show_description), bool_from_yn($cat->show_rating), |
|---|
| 69 |
$cat->list_limit, bool_from_yn($cat->show_updated)); |
|---|
| 70 |
} else { |
|---|
| 71 |
$args = add_query_arg('category', $cat->cat_id, $args); |
|---|
| 72 |
wp_get_links($args); |
|---|
| 73 |
} |
|---|
| 74 |
} |
|---|
| 75 |
|
|---|
| 76 |
/** function wp_get_links() |
|---|
| 77 |
** Gets the links associated with category n. |
|---|
| 78 |
** Parameters: |
|---|
| 79 |
** category (no default) - The category to use. |
|---|
| 80 |
** or: |
|---|
| 81 |
** a query string |
|---|
| 82 |
**/ |
|---|
| 83 |
function wp_get_links($args = '') { |
|---|
| 84 |
global $wpdb; |
|---|
| 85 |
|
|---|
| 86 |
if (!empty($args) && false === strpos($args, '=')) { |
|---|
| 87 |
|
|---|
| 88 |
$category = $args; |
|---|
| 89 |
$cat = $wpdb->get_row("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, " |
|---|
| 90 |
. " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, " |
|---|
| 91 |
. " text_after_all, list_limit FROM $wpdb->linkcategories WHERE cat_id=$category"); |
|---|
| 92 |
if ($cat) { |
|---|
| 93 |
if ($cat->sort_desc == 'Y') { |
|---|
| 94 |
$cat->sort_order = '_'.$cat->sort_order; |
|---|
| 95 |
} |
|---|
| 96 |
get_links($cat->cat_id, $cat->text_before_link, $cat->text_after_all, |
|---|
| 97 |
$cat->text_after_link, bool_from_yn($cat->show_images), $cat->sort_order, |
|---|
| 98 |
bool_from_yn($cat->show_description), bool_from_yn($cat->show_rating), |
|---|
| 99 |
$cat->list_limit, bool_from_yn($cat->show_updated)); |
|---|
| 100 |
} |
|---|
| 101 |
} else { |
|---|
| 102 |
parse_str($args); |
|---|
| 103 |
|
|---|
| 104 |
if (! isset($category)) $category = -1; |
|---|
| 105 |
if (! isset($before)) $before = ''; |
|---|
| 106 |
if (! isset($after)) $after = '<br />'; |
|---|
| 107 |
if (! isset($between)) $between = ' '; |
|---|
| 108 |
if (! isset($show_images)) $show_images = true; |
|---|
| 109 |
if (! isset($orderby)) $orderby = 'name'; |
|---|
| 110 |
if (! isset($show_description)) $show_description = true; |
|---|
| 111 |
if (! isset($show_rating)) $show_rating = false; |
|---|
| 112 |
if (! isset($limit)) $limit = -1; |
|---|
| 113 |
if (! isset($show_updated)) $show_updated = 1; |
|---|
| 114 |
if (! isset($echo)) $echo = true; |
|---|
| 115 |
|
|---|
| 116 |
get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated, $echo); |
|---|
| 117 |
} |
|---|
| 118 |
} |
|---|
| 119 |
|
|---|
| 120 |
/** function get_links() |
|---|
| 121 |
** Gets the links associated with category n. |
|---|
| 122 |
** Parameters: |
|---|
| 123 |
** category (default -1) - The category to use. If no category supplied |
|---|
| 124 |
** uses all |
|---|
| 125 |
** before (default '') - the html to output before the link |
|---|
| 126 |
** after (default '<br />') - the html to output after the link |
|---|
| 127 |
** between (default ' ') - the html to output between the link/image |
|---|
| 128 |
** and it's description. Not used if no image or show_images == true |
|---|
| 129 |
** show_images (default true) - whether to show images (if defined). |
|---|
| 130 |
** orderby (default 'id') - the order to output the links. E.g. 'id', 'name', |
|---|
| 131 |
** 'url', 'description', or 'rating'. Or maybe owner. If you start the |
|---|
| 132 |
** name with an underscore the order will be reversed. |
|---|
| 133 |
** You can also specify 'rand' as the order which will return links in a |
|---|
| 134 |
** random order. |
|---|
| 135 |
** show_description (default true) - whether to show the description if |
|---|
| 136 |
** show_images=false/not defined . |
|---|
| 137 |
** show_rating (default false) - show rating stars/chars |
|---|
| 138 |
** limit (default -1) - Limit to X entries. If not specified, all entries |
|---|
| 139 |
** are shown. |
|---|
| 140 |
** show_updated (default 0) - whether to show last updated timestamp |
|---|
| 141 |
*/ |
|---|
| 142 |
function get_links($category = -1, $before = '', $after = '<br />', |
|---|
| 143 |
$between = ' ', $show_images = true, $orderby = 'name', |
|---|
| 144 |
$show_description = true, $show_rating = false, |
|---|
| 145 |
$limit = -1, $show_updated = 1, $echo = true) { |
|---|
| 146 |
|
|---|
| 147 |
global $wpdb; |
|---|
| 148 |
|
|---|
| 149 |
$direction = ' ASC'; |
|---|
| 150 |
$category_query = ""; |
|---|
| 151 |
if ($category != -1) { |
|---|
| 152 |
$category_query = " AND link_category = $category "; |
|---|
| 153 |
} |
|---|
| 154 |
if (get_settings('links_recently_updated_time')) { |
|---|
| 155 |
$recently_updated_test = ", IF (DATE_ADD(link_updated, INTERVAL ".get_settings('links_recently_updated_time')." MINUTE) >= NOW(), 1,0) as recently_updated "; |
|---|
| 156 |
} else { |
|---|
| 157 |
$recently_updated_test = ''; |
|---|
| 158 |
} |
|---|
| 159 |
if ($show_updated) { |
|---|
| 160 |
$get_updated = ", UNIX_TIMESTAMP(link_updated) AS link_updated_f "; |
|---|
| 161 |
} |
|---|
| 162 |
|
|---|
| 163 |
$orderby=strtolower($orderby); |
|---|
| 164 |
if ($orderby == '') |
|---|
| 165 |
$orderby = 'id'; |
|---|
| 166 |
if (substr($orderby,0,1) == '_') { |
|---|
| 167 |
$direction = ' DESC'; |
|---|
| 168 |
$orderby = substr($orderby,1); |
|---|
| 169 |
} |
|---|
| 170 |
|
|---|
| 171 |
switch($orderby) { |
|---|
| 172 |
case 'length': |
|---|
| 173 |
$length = ",CHAR_LENGTH(link_name) AS length"; |
|---|
| 174 |
break; |
|---|
| 175 |
case 'rand': |
|---|
| 176 |
$orderby = 'rand()'; |
|---|
| 177 |
break; |
|---|
| 178 |
default: |
|---|
| 179 |
$orderby = " link_" . $orderby; |
|---|
| 180 |
} |
|---|
| 181 |
|
|---|
| 182 |
if (!isset($length)) { |
|---|
| 183 |
$length = ""; |
|---|
| 184 |
} |
|---|
| 185 |
|
|---|
| 186 |
$sql = "SELECT link_url, link_name, link_image, link_target, |
|---|
| 187 |
link_description, link_rating, link_rel $length $recently_updated_test $get_updated |
|---|
| 188 |
FROM $wpdb->links |
|---|
| 189 |
WHERE link_visible = 'Y' " . |
|---|
| 190 |
$category_query; |
|---|
| 191 |
$sql .= ' ORDER BY ' . $orderby; |
|---|
| 192 |
$sql .= $direction; |
|---|
| 193 |
|
|---|
| 194 |
if ($limit != -1) |
|---|
| 195 |
$sql .= " LIMIT $limit"; |
|---|
| 196 |
|
|---|
| 197 |
$results = $wpdb->get_results($sql); |
|---|
| 198 |
if (!$results) { |
|---|
| 199 |
return; |
|---|
| 200 |
} |
|---|
| 201 |
|
|---|
| 202 |
$output = ""; |
|---|
| 203 |
|
|---|
| 204 |
foreach ($results as $row) { |
|---|
| 205 |
if (!isset($row->recently_updated)) $row->recently_updated = false; |
|---|
| 206 |
$output .= ($before); |
|---|
| 207 |
|
|---|
| 208 |
if ($show_updated && $row->recently_updated) { |
|---|
| 209 |
$output .= get_settings('links_recently_updated_prepend'); |
|---|
| 210 |
} |
|---|
| 211 |
|
|---|
| 212 |
$the_link = '#'; |
|---|
| 213 |
|
|---|
| 214 |
if ( !empty($row->link_url) ) |
|---|
| 215 |
$the_link = wp_specialchars($row->link_url); |
|---|
| 216 |
$rel = $row->link_rel; |
|---|
| 217 |
|
|---|
| 218 |
if ($rel != '') { |
|---|
| 219 |
$rel = " rel='$rel'"; |
|---|
| 220 |
} |
|---|
| 221 |
|
|---|
| 222 |
$desc = wp_specialchars($row->link_description, ENT_QUOTES); |
|---|
| 223 |
$name = wp_specialchars($row->link_name, ENT_QUOTES); |
|---|
| 224 |
|
|---|
| 225 |
$title = $desc; |
|---|
| 226 |
|
|---|
| 227 |
if ($show_updated) { |
|---|
| 228 |
if (substr($row->link_updated_f,0,2) != '00') { |
|---|
| 229 |
$title .= ' (Last updated ' . date(get_settings('links_updated_date_format'), $row->link_updated_f + (get_settings('gmt_offset') * 3600)) .')'; |
|---|
| 230 |
} |
|---|
| 231 |
} |
|---|
| 232 |
|
|---|
| 233 |
if ('' != $title) { |
|---|
| 234 |
$title = " title='$title'"; |
|---|
| 235 |
} |
|---|
| 236 |
|
|---|
| 237 |
$alt = " alt='$name'"; |
|---|
| 238 |
|
|---|
| 239 |
$target = $row->link_target; |
|---|
| 240 |
if ('' != $target) { |
|---|
| 241 |
$target = " target='$target'"; |
|---|
| 242 |
} |
|---|
| 243 |
|
|---|
| 244 |
$output.= "<a href='$the_link'"; |
|---|
| 245 |
$output.= $rel . $title . $target; |
|---|
| 246 |
$output.= '>'; |
|---|
| 247 |
|
|---|
| 248 |
if (($row->link_image != null) && $show_images) { |
|---|
| 249 |
if (strstr($row->link_image, 'http')) |
|---|
| 250 |
$output.= "<img src='$row->link_image' $alt $title />"; |
|---|
| 251 |
else |
|---|
| 252 |
$output.= "<img src='" . get_settings('siteurl') . "$row->link_image' $alt $title />"; |
|---|
| 253 |
} else { |
|---|
| 254 |
$output.= $name; |
|---|
| 255 |
} |
|---|
| 256 |
|
|---|
| 257 |
$output.= '</a>'; |
|---|
| 258 |
|
|---|
| 259 |
if ($show_updated && $row->recently_updated) { |
|---|
| 260 |
$output.= get_settings('links_recently_updated_append'); |
|---|
| 261 |
} |
|---|
| 262 |
|
|---|
| 263 |
if ($show_description && ($desc != '')) { |
|---|
| 264 |
$output.= $between.$desc; |
|---|
| 265 |
} |
|---|
| 266 |
$output.= "$after\n"; |
|---|
| 267 |
} |
|---|
| 268 |
|
|---|
| 269 |
if($echo) { |
|---|
| 270 |
echo $output; |
|---|
| 271 |
} else { |
|---|
| 272 |
return $output; |
|---|
| 273 |
} |
|---|
| 274 |
} |
|---|
| 275 |
|
|---|
| 276 |
|
|---|
| 277 |
|
|---|
| 278 |
|
|---|
| 279 |
|
|---|
| 280 |
|
|---|
| 281 |
|
|---|
| 282 |
|
|---|
| 283 |
|
|---|
| 284 |
|
|---|
| 285 |
|
|---|
| 286 |
|
|---|
| 287 |
|
|---|
| 288 |
|
|---|
| 289 |
|
|---|
| 290 |
|
|---|
| 291 |
|
|---|
| 292 |
|
|---|
| 293 |
|
|---|
| 294 |
|
|---|
| 295 |
|
|---|
| 296 |
function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) { |
|---|
| 297 |
global $wpdb; |
|---|
| 298 |
$cat_id = -1; |
|---|
| 299 |
$results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'"); |
|---|
| 300 |
if ($results) { |
|---|
| 301 |
foreach ($results as $result) { |
|---|
| 302 |
$cat_id = $result->cat_id; |
|---|
| 303 |
} |
|---|
| 304 |
} |
|---|
| 305 |
return get_linkobjects($cat_id, $orderby, $limit); |
|---|
| 306 |
} |
|---|
| 307 |
|
|---|
| 308 |
|
|---|
| 309 |
|
|---|
| 310 |
|
|---|
| 311 |
|
|---|
| 312 |
|
|---|
| 313 |
|
|---|
| 314 |
|
|---|
| 315 |
|
|---|
| 316 |
|
|---|
| 317 |
|
|---|
| 318 |
|
|---|
| 319 |
|
|---|
| 320 |
|
|---|
| 321 |
|
|---|
| 322 |
|
|---|
| 323 |
|
|---|
| 324 |
|
|---|
| 325 |
|
|---|
| 326 |
|
|---|
| 327 |
|
|---|
| 328 |
|
|---|
| 329 |
|
|---|
| 330 |
|
|---|
| 331 |
|
|---|
| 332 |
|
|---|
| 333 |
|
|---|
| 334 |
|
|---|
| 335 |
|
|---|
| 336 |
|
|---|
| 337 |
|
|---|
| 338 |
|
|---|
| 339 |
|
|---|
| 340 |
|
|---|
| 341 |
|
|---|
| 342 |
|
|---|
| 343 |
function get_linkobjects($category = -1, $orderby = 'name', $limit = -1) { |
|---|
| 344 |
global $wpdb; |
|---|
| 345 |
|
|---|
| 346 |
$sql = "SELECT * FROM $wpdb->links WHERE link_visible = 'Y'"; |
|---|
| 347 |
if ($category != -1) { |
|---|
| 348 |
$sql .= " AND link_category = $category "; |
|---|
| 349 |
} |
|---|
| 350 |
if ($orderby == '') |
|---|
| 351 |
$orderby = 'id'; |
|---|
| 352 |
if (substr($orderby,0,1) == '_') { |
|---|
| 353 |
$direction = ' DESC'; |
|---|
| 354 |
$orderby = substr($orderby,1); |
|---|
| 355 |
} |
|---|
| 356 |
if (strcasecmp('rand',$orderby) == 0) { |
|---|
| 357 |
$orderby = 'rand()'; |
|---|
| 358 |
} else { |
|---|
| 359 |
$orderby = " link_" . $orderby; |
|---|
| 360 |
} |
|---|
| 361 |
$sql .= ' ORDER BY ' . $orderby; |
|---|
| 362 |
$sql .= $direction; |
|---|
| 363 |
|
|---|
| 364 |
if ($limit != -1) |
|---|
| 365 |
$sql .= " LIMIT $limit"; |
|---|
| 366 |
|
|---|
| 367 |
$results = $wpdb->get_results($sql); |
|---|
| 368 |
if ($results) { |
|---|
| 369 |
foreach ($results as $result) { |
|---|
| 370 |
$result->link_url = $result->link_url; |
|---|
| 371 |
$result->link_name = $result->link_name; |
|---|
| 372 |
$result->link_description = $result->link_description; |
|---|
| 373 |
$result->link_notes = $result->link_notes; |
|---|
| 374 |
$newresults[] = $result; |
|---|
| 375 |
} |
|---|
| 376 |
} |
|---|
| 377 |
return $newresults; |
|---|
| 378 |
} |
|---|
| 379 |
|
|---|
| 380 |
function get_linkrating($link) { |
|---|
| 381 |
return apply_filters('link_rating', $link->link_rating); |
|---|
| 382 |
} |
|---|
| 383 |
|
|---|
| 384 |
|
|---|
| 385 |
|
|---|
| 386 |
|
|---|
| 387 |
|
|---|
| 388 |
|
|---|
| 389 |
|
|---|
| 390 |
|
|---|
| 391 |
|
|---|
| 392 |
|
|---|
| 393 |
|
|---|
| 394 |
|
|---|
| 395 |
|
|---|
| 396 |
|
|---|
| 397 |
|
|---|
| 398 |
|
|---|
| 399 |
|
|---|
| 400 |
|
|---|
| 401 |
|
|---|
| 402 |
|
|---|
| 403 |
|
|---|
| 404 |
|
|---|
| 405 |
|
|---|
| 406 |
function get_linksbyname_withrating($cat_name = "noname", $before = '', |
|---|
| 407 |
$after = '<br />', $between = " ", |
|---|
| 408 |
$show_images = true, $orderby = 'id', |
|---|
| 409 |
$show_description = true, $limit = -1, $show_updated = 0) { |
|---|
| 410 |
|
|---|
| 411 |
get_linksbyname($cat_name, $before, $after, $between, $show_images, |
|---|
| 412 |
$orderby, $show_description, true, $limit, $show_updated); |
|---|
| 413 |
} |
|---|
| 414 |
|
|---|
| 415 |
|
|---|
| 416 |
|
|---|
| 417 |
|
|---|
| 418 |
|
|---|
| 419 |
|
|---|
| 420 |
|
|---|
| 421 |
|
|---|
| 422 |
|
|---|
| 423 |
|
|---|
| 424 |
|
|---|
| 425 |
|
|---|
| 426 |
|
|---|
| 427 |
|
|---|
| 428 |
|
|---|
| 429 |
|
|---|
| 430 |
|
|---|
| 431 |
|
|---|
| 432 |
|
|---|
| 433 |
|
|---|
| 434 |
|
|---|
| 435 |
|
|---|
| 436 |
function get_links_withrating($category = -1, $before = '', $after = '<br />', |
|---|
| 437 |
$between = " ", $show_images = true, |
|---|
| 438 |
$orderby = 'id', $show_description = true, |
|---|
| 439 |
$limit = -1, $show_updated = 0) { |
|---|
| 440 |
|
|---|
| 441 |
get_links($category, $before, $after, $between, $show_images, $orderby, |
|---|
| 442 |
$show_description, true, $limit, $show_updated); |
|---|
| 443 |
} |
|---|
| 444 |
|
|---|
| 445 |
|
|---|
| 446 |
|
|---|
| 447 |
|
|---|
| 448 |
|
|---|
| 449 |
|
|---|
| 450 |
function get_linkcatname($id = 0) { |
|---|
| 451 |
global $wpdb; |
|---|
| 452 |
$cat_name = ''; |
|---|
| 453 |
if ('' != $id) { |
|---|
| 454 |
$cat_name = $wpdb->get_var("SELECT cat_name FROM $wpdb->linkcategories WHERE cat_id=$id"); |
|---|
| 455 |
} |
|---|
| 456 |
return $cat_name; |
|---|
| 457 |
} |
|---|
| 458 |
|
|---|
| 459 |
|
|---|
| 460 |
|
|---|
| 461 |
|
|---|
| 462 |
|
|---|
| 463 |
|
|---|
| 464 |
function get_autotoggle($id = 0) { |
|---|
| 465 |
global $wpdb; |
|---|
| 466 |
$auto_toggle = $wpdb->get_var("SELECT auto_toggle FROM $wpdb->linkcategories WHERE cat_id=$id"); |
|---|
| 467 |
if ('' == $auto_toggle) |
|---|
| 468 |
$auto_toggle = 'N'; |
|---|
| 469 |
return $auto_toggle; |
|---|
| 470 |
} |
|---|
| 471 |
|
|---|
| 472 |
|
|---|
| 473 |
|
|---|
| 474 |
|
|---|
| 475 |
|
|---|
| 476 |
|
|---|
| 477 |
|
|---|
| 478 |
|
|---|
| 479 |
|
|---|
| 480 |
|
|---|
| 481 |
|
|---|
| 482 |
function links_popup_script($text = 'Links', $width=400, $height=400, |
|---|
| 483 |
$file='links.all.php', $count = true) { |
|---|
| 484 |
if ($count == true) { |
|---|
| 485 |
$counts = $wpdb->get_var("SELECT count(*) FROM $wpdb->links"); |
|---|
| 486 |
} |
|---|
| 487 |
|
|---|
| 488 |
$javascript = "<a href=\"#\" " . |
|---|
| 489 |
" onclick=\"javascript:window.open('$file?popup=1', '_blank', " . |
|---|
| 490 |
"'width=$width,height=$height,scrollbars=yes,status=no'); " . |
|---|
| 491 |
" return false\">"; |
|---|
| 492 |
$javascript .= $text; |
|---|
| 493 |
|
|---|
| 494 |
if ($count == true) { |
|---|
| 495 |
$javascript .= " ($counts)"; |
|---|
| 496 |
} |
|---|
| 497 |
|
|---|
| 498 |
$javascript .="</a>\n\n"; |
|---|
| 499 |
echo $javascript; |
|---|
| 500 |
} |
|---|
| 501 |
|
|---|
| 502 |
|
|---|
| 503 |
|
|---|
| 504 |
|
|---|
| 505 |
|
|---|
| 506 |
|
|---|
| 507 |
|
|---|
| 508 |
|
|---|
| 509 |
|
|---|
| 510 |
|
|---|
| 511 |
|
|---|
| 512 |
|
|---|
| 513 |
|
|---|
| 514 |
|
|---|
| 515 |
|
|---|
| 516 |
function get_links_list($order = 'name', $hide_if_empty = 'obsolete') { |
|---|
| 517 |
global $wpdb; |
|---|
| 518 |
|
|---|
| 519 |
$order = strtolower($order); |
|---|
| 520 |
|
|---|
| 521 |
|
|---|
| 522 |
if (substr($order,0,1) == '_') { |
|---|
| 523 |
$direction = ' DESC'; |
|---|
| 524 |
$order = substr($order,1); |
|---|
| 525 |
} |
|---|
| 526 |
|
|---|
| 527 |
|
|---|
| 528 |
$cat_order = ('name' == $order) ? 'cat_name' : 'cat_id'; |
|---|
| 529 |
|
|---|
| 530 |
if (!isset($direction)) $direction = ''; |
|---|
| 531 |
|
|---|
| 532 |
$cats = $wpdb->get_results(" |
|---|
| 533 |
SELECT DISTINCT link_category, cat_name, show_images, |
|---|
| 534 |
show_description, show_rating, show_updated, sort_order, |
|---|
| 535 |
sort_desc, list_limit |
|---|
| 536 |
FROM `$wpdb->links` |
|---|
| 537 |
LEFT JOIN `$wpdb->linkcategories` ON (link_category = cat_id) |
|---|
| 538 |
WHERE link_visible = 'Y' |
|---|
| 539 |
AND list_limit <> 0 |
|---|
| 540 |
ORDER BY $cat_order $direction ", ARRAY_A); |
|---|
| 541 |
|
|---|
| 542 |
|
|---|
| 543 |
if ($cats) { |
|---|
| 544 |
&nbs |
|---|