Make WordPress Core


Ignore:
Timestamp:
03/02/2006 03:27:48 AM (19 years ago)
Author:
ryan
Message:

Move deprecated functions to deprecated.php. #2520

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/links.php

    r3570 r3589  
    11<?php
    2 
    3 /** function get_linksbyname()
    4  ** Gets the links associated with category 'cat_name'.
    5  ** Parameters:
    6  **   cat_name (default 'noname')  - The category name to use. If no
    7  **     match is found uses all
    8  **   before (default '')  - the html to output before the link
    9  **   after (default '<br />')  - the html to output after the link
    10  **   between (default ' ')  - the html to output between the link/image
    11  **     and it's description. Not used if no image or show_images == true
    12  **   show_images (default true) - whether to show images (if defined).
    13  **   orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
    14  **     'url', 'description' or 'rating'. Or maybe owner. If you start the
    15  **     name with an underscore the order will be reversed.
    16  **     You can also specify 'rand' as the order which will return links in a
    17  **     random order.
    18  **   show_description (default true) - whether to show the description if
    19  **     show_images=false/not defined
    20  **   show_rating (default false) - show rating stars/chars
    21  **   limit (default -1) - Limit to X entries. If not specified, all entries
    22  **     are shown.
    23  **   show_updated (default 0) - whether to show last updated timestamp
    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->categories 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 wp_get_linksbyname()
    42  ** Gets the links associated with the named category.
    43  ** Parameters:
    44  **   category (no default)  - The category to use.
    45  **/
    46 function wp_get_linksbyname($category, $args = '') {
    47     global $wpdb;
    48 
    49     $cat_id = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$category' LIMIT 1");
    50 
    51     if (! $cat_id)
    52         return;
    53 
    54     $args = add_query_arg('category', $cat_id, $args);
    55     wp_get_links($args);
    56 } // end wp_get_linksbyname
    572
    583/** function wp_get_links()
     
    204149}
    205150
    206 
    207 /** function get_linkobjectsbyname()
    208  ** Gets an array of link objects associated with category 'cat_name'.
    209  ** Parameters:
    210  **   cat_name (default 'noname')  - The category name to use. If no
    211  **     match is found uses all
    212  **   orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
    213  **     'url', 'description', or 'rating'. Or maybe owner. If you start the
    214  **     name with an underscore the order will be reversed.
    215  **     You can also specify 'rand' as the order which will return links in a
    216  **     random order.
    217  **   limit (default -1) - Limit to X entries. If not specified, all entries
    218  **     are shown.
    219  **
    220  ** Use this like:
    221  ** $links = get_linkobjectsbyname('fred');
    222  ** foreach ($links as $link) {
    223  **   echo '<li>'.$link->link_name.'</li>';
    224  ** }
    225  **/
    226 // Deprecate in favor of get_linkz().
    227 function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) {
    228     global $wpdb;
    229     $cat_id = -1;
    230     //$results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'");
    231     // TODO: Fix me.
    232     if ($results) {
    233         foreach ($results as $result) {
    234             $cat_id = $result->cat_id;
    235         }
    236     }
    237     return get_linkobjects($cat_id, $orderby, $limit);
    238 }
    239 
    240 /** function get_linkobjects()
    241  ** Gets an array of link objects associated with category n.
    242  ** Parameters:
    243  **   category (default -1)  - The category to use. If no category supplied
    244  **      uses all
    245  **   orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
    246  **     'url', 'description', or 'rating'. Or maybe owner. If you start the
    247  **     name with an underscore the order will be reversed.
    248  **     You can also specify 'rand' as the order which will return links in a
    249  **     random order.
    250  **   limit (default -1) - Limit to X entries. If not specified, all entries
    251  **     are shown.
    252  **
    253  ** Use this like:
    254  ** $links = get_linkobjects(1);
    255  ** if ($links) {
    256  **   foreach ($links as $link) {
    257  **     echo '<li>'.$link->link_name.'<br />'.$link->link_description.'</li>';
    258  **   }
    259  ** }
    260  ** Fields are:
    261  ** link_id
    262  ** link_url
    263  ** link_name
    264  ** link_image
    265  ** link_target
    266  ** link_category
    267  ** link_description
    268  ** link_visible
    269  ** link_owner
    270  ** link_rating
    271  ** link_updated
    272  ** link_rel
    273  ** link_notes
    274  **/
    275 // Deprecate in favor of get_linkz().
    276 function get_linkobjects($category = -1, $orderby = 'name', $limit = -1) {
    277     global $wpdb;
    278 
    279     $sql = "SELECT * FROM $wpdb->links WHERE link_visible = 'Y'";
    280     if ($category != -1) {
    281         $sql .= " AND link_category = $category ";
    282     }
    283     if ($orderby == '')
    284         $orderby = 'id';
    285     if (substr($orderby,0,1) == '_') {
    286         $direction = ' DESC';
    287         $orderby = substr($orderby,1);
    288     }
    289     if (strcasecmp('rand',$orderby) == 0) {
    290         $orderby = 'rand()';
    291     } else {
    292         $orderby = " link_" . $orderby;
    293     }
    294     $sql .= ' ORDER BY ' . $orderby;
    295     $sql .= $direction;
    296     /* The next 2 lines implement LIMIT TO processing */
    297     if ($limit != -1)
    298         $sql .= " LIMIT $limit";
    299 
    300     $results = $wpdb->get_results($sql);
    301     if ($results) {
    302         foreach ($results as $result) {
    303             $result->link_url         = $result->link_url;
    304             $result->link_name        = $result->link_name;
    305             $result->link_description = $result->link_description;
    306             $result->link_notes       = $result->link_notes;
    307             $newresults[] = $result;
    308         }
    309     }
    310     return $newresults;
    311 }
    312 
    313151function get_linkrating($link) {
    314152    return apply_filters('link_rating', $link->link_rating);
    315 }
    316 
    317 
    318 /** function get_linksbyname_withrating()
    319  ** Gets the links associated with category 'cat_name' and display rating stars/chars.
    320  ** Parameters:
    321  **   cat_name (default 'noname')  - The category name to use. If no
    322  **     match is found uses all
    323  **   before (default '')  - the html to output before the link
    324  **   after (default '<br />')  - the html to output after the link
    325  **   between (default ' ')  - the html to output between the link/image
    326  **     and it's description. Not used if no image or show_images == true
    327  **   show_images (default true) - whether to show images (if defined).
    328  **   orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
    329  **     'url' or 'description'. Or maybe owner. If you start the
    330  **     name with an underscore the order will be reversed.
    331  **     You can also specify 'rand' as the order which will return links in a
    332  **     random order.
    333  **   show_description (default true) - whether to show the description if
    334  **     show_images=false/not defined
    335  **   limit (default -1) - Limit to X entries. If not specified, all entries
    336  **     are shown.
    337  **   show_updated (default 0) - whether to show last updated timestamp
    338  */
    339 function get_linksbyname_withrating($cat_name = "noname", $before = '',
    340                                     $after = '<br />', $between = " ",
    341                                     $show_images = true, $orderby = 'id',
    342                                     $show_description = true, $limit = -1, $show_updated = 0) {
    343 
    344     get_linksbyname($cat_name, $before, $after, $between, $show_images,
    345                     $orderby, $show_description, true, $limit, $show_updated);
    346 }
    347 
    348 /** function get_links_withrating()
    349  ** Gets the links associated with category n and display rating stars/chars.
    350  ** Parameters:
    351  **   category (default -1)  - The category to use. If no category supplied
    352  **      uses all
    353  **   before (default '')  - the html to output before the link
    354  **   after (default '<br />')  - the html to output after the link
    355  **   between (default ' ')  - the html to output between the link/image
    356  **     and it's description. Not used if no image or show_images == true
    357  **   show_images (default true) - whether to show images (if defined).
    358  **   orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
    359  **     'url' or 'description'. Or maybe owner. If you start the
    360  **     name with an underscore the order will be reversed.
    361  **     You can also specify 'rand' as the order which will return links in a
    362  **     random order.
    363  **   show_description (default true) - whether to show the description if
    364  **    show_images=false/not defined .
    365  **   limit (default -1) - Limit to X entries. If not specified, all entries
    366  **     are shown.
    367  **   show_updated (default 0) - whether to show last updated timestamp
    368  */
    369 function get_links_withrating($category = -1, $before = '', $after = '<br />',
    370                               $between = " ", $show_images = true,
    371                               $orderby = 'id', $show_description = true,
    372                               $limit = -1, $show_updated = 0) {
    373 
    374     get_links($category, $before, $after, $between, $show_images, $orderby,
    375               $show_description, true, $limit, $show_updated);
    376153}
    377154
     
    394171    $cat = get_category($cat_id);
    395172    return $cat->cat_name;
    396 }
    397 
    398 /** function get_get_autotoggle()
    399  ** Gets the auto_toggle setting of category n.
    400  ** Parameters: id (default 0)  - The category to get. If no category supplied
    401  **                uses 0
    402  */
    403 function get_autotoggle($id = 0) {
    404     return 0; 
    405173}
    406174
Note: See TracChangeset for help on using the changeset viewer.