Changeset 6088 for trunk/wp-includes/deprecated.php
- Timestamp:
- 09/12/2007 01:01:48 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/deprecated.php
r5910 r6088 490 490 } 491 491 492 /** function wp_get_links() 493 ** Gets the links associated with category n. 494 ** Parameters: 495 ** category (no default) - The category to use. 496 ** or: 497 ** a query string 498 **/ 499 function wp_get_links($args = '') { 500 global $wpdb; 501 502 if ( strpos( $args, '=' ) === false ) { 503 $cat_id = $args; 504 $args = add_query_arg( 'category', $cat_id, $args ); 505 } 506 507 $defaults = array( 508 'category' => -1, 'before' => '', 509 'after' => '<br />', 'between' => ' ', 510 'show_images' => true, 'orderby' => 'name', 511 'show_description' => true, 'show_rating' => false, 512 'limit' => -1, 'show_updated' => true, 513 'echo' => true 514 ); 515 516 $r = wp_parse_args( $args, $defaults ); 517 extract( $r, EXTR_SKIP ); 518 519 return get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated, $echo); 520 } // end wp_get_links 521 522 /** function get_links() 523 ** Gets the links associated with category n. 524 ** Parameters: 525 ** category (default -1) - The category to use. If no category supplied 526 ** uses all 527 ** before (default '') - the html to output before the link 528 ** after (default '<br />') - the html to output after the link 529 ** between (default ' ') - the html to output between the link/image 530 ** and its description. Not used if no image or show_images == true 531 ** show_images (default true) - whether to show images (if defined). 532 ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name', 533 ** 'url', 'description', or 'rating'. Or maybe owner. If you start the 534 ** name with an underscore the order will be reversed. 535 ** You can also specify 'rand' as the order which will return links in a 536 ** random order. 537 ** show_description (default true) - whether to show the description if 538 ** show_images=false/not defined . 539 ** show_rating (default false) - show rating stars/chars 540 ** limit (default -1) - Limit to X entries. If not specified, all entries 541 ** are shown. 542 ** show_updated (default 0) - whether to show last updated timestamp 543 ** echo (default true) - whether to echo the results, or return them instead 544 */ 545 function get_links($category = -1, 546 $before = '', 547 $after = '<br />', 548 $between = ' ', 549 $show_images = true, 550 $orderby = 'name', 551 $show_description = true, 552 $show_rating = false, 553 $limit = -1, 554 $show_updated = 1, 555 $echo = true) { 556 557 global $wpdb; 558 559 $order = 'ASC'; 560 if ( substr($orderby, 0, 1) == '_' ) { 561 $order = 'DESC'; 562 $orderby = substr($orderby, 1); 563 } 564 565 if ( $category == -1 ) //get_bookmarks uses '' to signify all categories 566 $category = ''; 567 568 $results = get_bookmarks("category=$category&orderby=$orderby&order=$order&show_updated=$show_updated&limit=$limit"); 569 570 if ( !$results ) 571 return; 572 573 $output = ''; 574 575 foreach ( (array) $results as $row ) { 576 if ( !isset($row->recently_updated) ) 577 $row->recently_updated = false; 578 $output .= $before; 579 if ( $show_updated && $row->recently_updated ) 580 $output .= get_option('links_recently_updated_prepend'); 581 $the_link = '#'; 582 if ( !empty($row->link_url) ) 583 $the_link = clean_url($row->link_url); 584 $rel = $row->link_rel; 585 if ( '' != $rel ) 586 $rel = ' rel="' . $rel . '"'; 587 588 $desc = attribute_escape($row->link_description); 589 $name = attribute_escape($row->link_name); 590 $title = $desc; 591 592 if ( $show_updated ) 593 if (substr($row->link_updated_f, 0, 2) != '00') 594 $title .= ' ('.__('Last updated') . ' ' . date(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * 3600)) . ')'; 595 596 if ( '' != $title ) 597 $title = ' title="' . $title . '"'; 598 599 $alt = ' alt="' . $name . '"'; 600 601 $target = $row->link_target; 602 if ( '' != $target ) 603 $target = ' target="' . $target . '"'; 604 605 $output .= '<a href="' . $the_link . '"' . $rel . $title . $target. '>'; 606 607 if ( $row->link_image != null && $show_images ) { 608 if ( strpos($row->link_image, 'http') !== false ) 609 $output .= "<img src=\"$row->link_image\" $alt $title />"; 610 else // If it's a relative path 611 $output .= "<img src=\"" . get_option('siteurl') . "$row->link_image\" $alt $title />"; 612 } else { 613 $output .= $name; 614 } 615 616 $output .= '</a>'; 617 618 if ( $show_updated && $row->recently_updated ) 619 $output .= get_option('links_recently_updated_append'); 620 621 if ( $show_description && '' != $desc ) 622 $output .= $between . $desc; 623 624 if ($show_rating) { 625 $output .= $between . get_linkrating($row); 626 } 627 628 $output .= "$after\n"; 629 } // end while 630 631 if ( !$echo ) 632 return $output; 633 echo $output; 634 } 635 636 /* 637 * function get_links_list() 638 * 639 * added by Dougal 640 * 641 * Output a list of all links, listed by category, using the 642 * settings in $wpdb->linkcategories and output it as a nested 643 * HTML unordered list. 644 * 645 * Parameters: 646 * order (default 'name') - Sort link categories by 'name' or 'id' 647 * hide_if_empty (default true) - Supress listing empty link categories 648 */ 649 function get_links_list($order = 'name', $hide_if_empty = 'obsolete') { 650 $order = strtolower($order); 651 652 // Handle link category sorting 653 $direction = 'ASC'; 654 if ( '_' == substr($order,0,1) ) { 655 $direction = 'DESC'; 656 $order = substr($order,1); 657 } 658 659 if ( !isset($direction) ) 660 $direction = ''; 661 662 $cats = get_categories("type=link&orderby=$order&order=$direction&hierarchical=0"); 663 664 // Display each category 665 if ( $cats ) { 666 foreach ( (array) $cats as $cat ) { 667 // Handle each category. 668 669 // Display the category name 670 echo ' <li id="linkcat-' . $cat->term_id . '" class="linkcat"><h2>' . $cat->name . "</h2>\n\t<ul>\n"; 671 // Call get_links() with all the appropriate params 672 get_links($cat->term_id, '<li>', "</li>", "\n", true, 'name', false); 673 674 // Close the last category 675 echo "\n\t</ul>\n</li>\n"; 676 } 677 } 678 } 679 680 681 /** function links_popup_script() 682 ** This function contributed by Fullo -- http://sprite.csr.unibo.it/fullo/ 683 ** Show the link to the links popup and the number of links 684 ** Parameters: 685 ** text (default Links) - the text of the link 686 ** width (default 400) - the width of the popup window 687 ** height (default 400) - the height of the popup window 688 ** file (default linkspopup.php) - the page to open in the popup window 689 ** count (default true) - the number of links in the db 690 */ 691 function links_popup_script($text = 'Links', $width=400, $height=400, $file='links.all.php', $count = true) { 692 if ( $count ) 693 $counts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->links"); 694 695 $javascript = "<a href=\"#\" onclick=\"javascript:window.open('$file?popup=1', '_blank', 'width=$width,height=$height,scrollbars=yes,status=no'); return false\">"; 696 $javascript .= $text; 697 698 if ( $count ) 699 $javascript .= " ($counts)"; 700 701 $javascript .= "</a>\n\n"; 702 echo $javascript; 703 } 704 705 706 function get_linkrating($link) { 707 return apply_filters('link_rating', $link->link_rating); 708 } 709 710 /** function get_linkcatname() 711 ** Gets the name of category n. 712 ** Parameters: id (default 0) - The category to get. If no category supplied 713 ** uses 0 714 */ 715 function get_linkcatname($id = 0) { 716 $id = (int) $id; 717 718 if ( empty($id) ) 719 return ''; 720 721 $cats = wp_get_link_cats($id); 722 723 if ( empty($cats) || ! is_array($cats) ) 724 return ''; 725 726 $cat_id = (int) $cats[0]; // Take the first cat. 727 728 $cat = get_category($cat_id); 729 return $cat->name; 730 } 731 492 732 ?>
Note: See TracChangeset
for help on using the changeset viewer.