Ticket #3413: 3413.diff

File 3413.diff, 10.1 kB (added by rob1n, 2 years ago)
  • wp-includes/deprecated.php

    old new  
    509509        return get_option($option); 
    510510} 
    511511 
     512// Use wp_list_bookmarks(). 
     513/** function get_links() 
     514 ** Gets the links associated with category n. 
     515 ** Parameters: 
     516 **   category (default -1)  - The category to use. If no category supplied 
     517 **      uses all 
     518 **   before (default '')  - the html to output before the link 
     519 **   after (default '<br />')  - the html to output after the link 
     520 **   between (default ' ')  - the html to output between the link/image 
     521 **     and its description. Not used if no image or show_images == true 
     522 **   show_images (default true) - whether to show images (if defined). 
     523 **   orderby (default 'id') - the order to output the links. E.g. 'id', 'name', 
     524 **     'url', 'description', or 'rating'. Or maybe owner. If you start the 
     525 **     name with an underscore the order will be reversed. 
     526 **     You can also specify 'rand' as the order which will return links in a 
     527 **     random order. 
     528 **   show_description (default true) - whether to show the description if 
     529 **    show_images=false/not defined . 
     530 **   show_rating (default false) - show rating stars/chars 
     531 **   limit (default -1) - Limit to X entries. If not specified, all entries 
     532 **     are shown. 
     533 **   show_updated (default 0) - whether to show last updated timestamp 
     534 **   echo (default true) - whether to echo the results, or return them instead 
     535 */ 
     536function get_links($category = -1, $before = '', $after = '<br />', $between = ' ', $show_images = true, $orderby = 'name', $show_description = true, $show_rating = false, $limit = -1, $show_updated = 1, $echo = true) { 
     537        global $wpdb; 
     538 
     539        $order = 'ASC'; 
     540        if ( substr($orderby, 0, 1) == '_' ) { 
     541                $order = 'DESC'; 
     542                $orderby = substr($orderby, 1); 
     543        } 
     544 
     545        if ( $category == -1 ) //get_bookmarks uses '' to signify all categories 
     546                $category = ''; 
     547 
     548        $results = get_bookmarks("category=$category&orderby=$orderby&order=$order&show_updated=$show_updated&limit=$limit"); 
     549 
     550        if ( !$results ) 
     551                return; 
     552 
     553        $output = ''; 
     554 
     555        foreach ( (array) $results as $row ) { 
     556                if ( !isset($row->recently_updated) ) 
     557                        $row->recently_updated = false; 
     558                $output .= $before; 
     559                if ( $show_updated && $row->recently_updated ) 
     560                        $output .= get_option('links_recently_updated_prepend'); 
     561                $the_link = '#'; 
     562                if ( !empty($row->link_url) ) 
     563                        $the_link = clean_url($row->link_url); 
     564                $rel = $row->link_rel; 
     565                if ( '' != $rel ) 
     566                        $rel = ' rel="' . $rel . '"'; 
     567 
     568                $desc = attribute_escape($row->link_description); 
     569                $name = attribute_escape($row->link_name); 
     570                $title = $desc; 
     571 
     572                if ( $show_updated ) 
     573                        if (substr($row->link_updated_f, 0, 2) != '00') 
     574                                $title .= ' ('.__('Last updated') . ' ' . date(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * 3600)) . ')'; 
     575 
     576                if ( '' != $title ) 
     577                        $title = ' title="' . $title . '"'; 
     578 
     579                $alt = ' alt="' . $name . '"'; 
     580 
     581                $target = $row->link_target; 
     582                if ( '' != $target ) 
     583                        $target = ' target="' . $target . '"'; 
     584 
     585                $output .= '<a href="' . $the_link . '"' . $rel . $title . $target. '>'; 
     586 
     587                if ( $row->link_image != null && $show_images ) { 
     588                        if ( strpos($row->link_image, 'http') !== false ) 
     589                                $output .= "<img src=\"$row->link_image\" $alt $title />"; 
     590                        else // If it's a relative path 
     591                                $output .= "<img src=\"" . get_option('siteurl') . "$row->link_image\" $alt $title />"; 
     592                } else { 
     593                        $output .= $name; 
     594                } 
     595 
     596                $output .= '</a>'; 
     597 
     598                if ( $show_updated && $row->recently_updated ) 
     599                        $output .= get_option('links_recently_updated_append'); 
     600 
     601                if ( $show_description && '' != $desc ) 
     602                        $output .= $between . $desc; 
     603                 
     604                if ($show_rating) { 
     605                        $output .= $between . get_linkrating($row); 
     606                } 
     607 
     608                $output .= "$after\n"; 
     609        } // end while 
     610 
     611        if ( !$echo ) 
     612                return $output; 
     613        echo $output; 
     614} 
     615 
     616// Use wp_list_bookmarks(). 
     617/* 
     618 * function get_links_list() 
     619 * 
     620 * added by Dougal 
     621 * 
     622 * Output a list of all links, listed by category, using the 
     623 * settings in $wpdb->linkcategories and output it as a nested 
     624 * HTML unordered list. 
     625 * 
     626 * Parameters: 
     627 *   order (default 'name')  - Sort link categories by 'name' or 'id' 
     628 *   hide_if_empty (default true)  - Supress listing empty link categories 
     629 */ 
     630function get_links_list($order = 'name', $hide_if_empty = 'obsolete') { 
     631        $r = array(); 
     632         
     633        $r['orderby'] = $order; 
     634         
     635        wp_list_bookmarks( $r ); 
     636} 
     637 
    512638?> 
  • wp-includes/bookmark-template.php

    old new  
    3030        return get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated, $echo); 
    3131} // end wp_get_links 
    3232 
    33 /** function get_links() 
    34  ** Gets the links associated with category n. 
    35  ** Parameters: 
    36  **   category (default -1)  - The category to use. If no category supplied 
    37  **      uses all 
    38  **   before (default '')  - the html to output before the link 
    39  **   after (default '<br />')  - the html to output after the link 
    40  **   between (default ' ')  - the html to output between the link/image 
    41  **     and its description. Not used if no image or show_images == true 
    42  **   show_images (default true) - whether to show images (if defined). 
    43  **   orderby (default 'id') - the order to output the links. E.g. 'id', 'name', 
    44  **     'url', 'description', or 'rating'. Or maybe owner. If you start the 
    45  **     name with an underscore the order will be reversed. 
    46  **     You can also specify 'rand' as the order which will return links in a 
    47  **     random order. 
    48  **   show_description (default true) - whether to show the description if 
    49  **    show_images=false/not defined . 
    50  **   show_rating (default false) - show rating stars/chars 
    51  **   limit (default -1) - Limit to X entries. If not specified, all entries 
    52  **     are shown. 
    53  **   show_updated (default 0) - whether to show last updated timestamp 
    54  **   echo (default true) - whether to echo the results, or return them instead 
    55  */ 
    56 function get_links($category = -1, 
    57                         $before = '', 
    58                         $after = '<br />', 
    59                         $between = ' ', 
    60                         $show_images = true, 
    61                         $orderby = 'name', 
    62                         $show_description = true, 
    63                         $show_rating = false, 
    64                         $limit = -1, 
    65                         $show_updated = 1, 
    66                         $echo = true) { 
    67  
    68         global $wpdb; 
    69  
    70         $order = 'ASC'; 
    71         if ( substr($orderby, 0, 1) == '_' ) { 
    72                 $order = 'DESC'; 
    73                 $orderby = substr($orderby, 1); 
    74         } 
    75  
    76         if ( $category == -1 ) //get_bookmarks uses '' to signify all categories 
    77                 $category = ''; 
    78  
    79         $results = get_bookmarks("category=$category&orderby=$orderby&order=$order&show_updated=$show_updated&limit=$limit"); 
    80  
    81         if ( !$results ) 
    82                 return; 
    83  
    84         $output = ''; 
    85  
    86         foreach ( (array) $results as $row ) { 
    87                 if ( !isset($row->recently_updated) ) 
    88                         $row->recently_updated = false; 
    89                 $output .= $before; 
    90                 if ( $show_updated && $row->recently_updated ) 
    91                         $output .= get_option('links_recently_updated_prepend'); 
    92                 $the_link = '#'; 
    93                 if ( !empty($row->link_url) ) 
    94                         $the_link = clean_url($row->link_url); 
    95                 $rel = $row->link_rel; 
    96                 if ( '' != $rel ) 
    97                         $rel = ' rel="' . $rel . '"'; 
    98  
    99                 $desc = attribute_escape($row->link_description); 
    100                 $name = attribute_escape($row->link_name); 
    101                 $title = $desc; 
    102  
    103                 if ( $show_updated ) 
    104                         if (substr($row->link_updated_f, 0, 2) != '00') 
    105                                 $title .= ' ('.__('Last updated') . ' ' . date(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * 3600)) . ')'; 
    106  
    107                 if ( '' != $title ) 
    108                         $title = ' title="' . $title . '"'; 
    109  
    110                 $alt = ' alt="' . $name . '"'; 
    111  
    112                 $target = $row->link_target; 
    113                 if ( '' != $target ) 
    114                         $target = ' target="' . $target . '"'; 
    115  
    116                 $output .= '<a href="' . $the_link . '"' . $rel . $title . $target. '>'; 
    117  
    118                 if ( $row->link_image != null && $show_images ) { 
    119                         if ( strpos($row->link_image, 'http') !== false ) 
    120                                 $output .= "<img src=\"$row->link_image\" $alt $title />"; 
    121                         else // If it's a relative path 
    122                                 $output .= "<img src=\"" . get_option('siteurl') . "$row->link_image\" $alt $title />"; 
    123                 } else { 
    124                         $output .= $name; 
    125                 } 
    126  
    127                 $output .= '</a>'; 
    128  
    129                 if ( $show_updated && $row->recently_updated ) 
    130                         $output .= get_option('links_recently_updated_append'); 
    131  
    132                 if ( $show_description && '' != $desc ) 
    133                         $output .= $between . $desc; 
    134                  
    135                 if ($show_rating) { 
    136                         $output .= $between . get_linkrating($row); 
    137                 } 
    138  
    139                 $output .= "$after\n"; 
    140         } // end while 
    141  
    142         if ( !$echo ) 
    143                 return $output; 
    144         echo $output; 
    145 } 
    146  
    14733function get_linkrating($link) { 
    14834        return apply_filters('link_rating', $link->link_rating); 
    14935} 
     
    19480                echo $javascript; 
    19581} 
    19682 
    197  
    198 /* 
    199  * function get_links_list() 
    200  * 
    201  * added by Dougal 
    202  * 
    203  * Output a list of all links, listed by category, using the 
    204  * settings in $wpdb->linkcategories and output it as a nested 
    205  * HTML unordered list. 
    206  * 
    207  * Parameters: 
    208  *   order (default 'name')  - Sort link categories by 'name' or 'id' 
    209  *   hide_if_empty (default true)  - Supress listing empty link categories 
    210  */ 
    211 function get_links_list($order = 'name', $hide_if_empty = 'obsolete') { 
    212         $order = strtolower($order); 
    213  
    214         // Handle link category sorting 
    215         $direction = 'ASC'; 
    216         if ( '_' == substr($order,0,1) ) { 
    217                 $direction = 'DESC'; 
    218                 $order = substr($order,1); 
    219         } 
    220  
    221         if ( !isset($direction) ) 
    222                 $direction = ''; 
    223  
    224         $cats = get_categories("type=link&orderby=$order&order=$direction&hierarchical=0"); 
    225  
    226         // Display each category 
    227         if ( $cats ) { 
    228                 foreach ( (array) $cats as $cat ) { 
    229                         // Handle each category. 
    230  
    231                         // Display the category name 
    232                         echo '  <li id="linkcat-' . $cat->cat_ID . '" class="linkcat"><h2>' . $cat->cat_name . "</h2>\n\t<ul>\n"; 
    233                         // Call get_links() with all the appropriate params 
    234                         get_links($cat->cat_ID, '<li>', "</li>", "\n", true, 'name', false); 
    235  
    236                         // Close the last category 
    237                         echo "\n\t</ul>\n</li>\n"; 
    238                 } 
    239         } 
    240 } 
    241  
    24283function _walk_bookmarks($bookmarks, $args = '' ) { 
    24384        $defaults = array( 
    24485                'show_updated' => 0, 'show_description' => 0,