Make WordPress Core

Changeset 3589


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

Move deprecated functions to deprecated.php. #2520

Location:
trunk
Files:
1 added
6 edited

Legend:

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

    r3566 r3589  
    435435}
    436436
    437 //
    438 // These are deprecated.  Use current_user_can().
    439 //
    440 
    441 /* returns true if $user_id can create a new post */
    442 function user_can_create_post($user_id, $blog_id = 1, $category_id = 'None') {
    443     $author_data = get_userdata($user_id);
    444     return ($author_data->user_level > 1);
    445 }
    446 
    447 /* returns true if $user_id can create a new post */
    448 function user_can_create_draft($user_id, $blog_id = 1, $category_id = 'None') {
    449     $author_data = get_userdata($user_id);
    450     return ($author_data->user_level >= 1);
    451 }
    452 
    453 /* returns true if $user_id can edit $post_id */
    454 function user_can_edit_post($user_id, $post_id, $blog_id = 1) {
    455     $author_data = get_userdata($user_id);
    456     $post = get_post($post_id);
    457     $post_author_data = get_userdata($post->post_author);
    458 
    459     if ( (($user_id == $post_author_data->ID) && !($post->post_status == 'publish' &&  $author_data->user_level < 2))
    460          || ($author_data->user_level > $post_author_data->user_level)
    461          || ($author_data->user_level >= 10) ) {
    462         return true;
    463     } else {
    464         return false;
    465     }
    466 }
    467 
    468 /* returns true if $user_id can delete $post_id */
    469 function user_can_delete_post($user_id, $post_id, $blog_id = 1) {
    470     // right now if one can edit, one can delete
    471     return user_can_edit_post($user_id, $post_id, $blog_id);
    472 }
    473 
    474 /* returns true if $user_id can set new posts' dates on $blog_id */
    475 function user_can_set_post_date($user_id, $blog_id = 1, $category_id = 'None') {
    476     $author_data = get_userdata($user_id);
    477     return (($author_data->user_level > 4) && user_can_create_post($user_id, $blog_id, $category_id));
    478 }
    479 
    480 /* returns true if $user_id can edit $post_id's date */
    481 function user_can_edit_post_date($user_id, $post_id, $blog_id = 1) {
    482     $author_data = get_userdata($user_id);
    483     return (($author_data->user_level > 4) && user_can_edit_post($user_id, $post_id, $blog_id));
    484 }
    485 
    486 /* returns true if $user_id can edit $post_id's comments */
    487 function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1) {
    488     // right now if one can edit a post, one can edit comments made on it
    489     return user_can_edit_post($user_id, $post_id, $blog_id);
    490 }
    491 
    492 /* returns true if $user_id can delete $post_id's comments */
    493 function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1) {
    494     // right now if one can edit comments, one can delete comments
    495     return user_can_edit_post_comments($user_id, $post_id, $blog_id);
    496 }
    497 
    498 function user_can_edit_user($user_id, $other_user) {
    499     $user  = get_userdata($user_id);
    500     $other = get_userdata($other_user);
    501     if ( $user->user_level > $other->user_level || $user->user_level > 8 || $user->ID == $other->ID )
    502         return true;
    503     else
    504         return false;
    505 }
    506 
    507437?>
  • trunk/wp-includes/functions.php

    r3582 r3589  
    536536
    537537    return true;
    538 }
    539 
    540 // Deprecated.  Use get_post().
    541 function get_postdata($postid) {
    542     $post = &get_post($postid);
    543 
    544     $postdata = array (
    545         'ID' => $post->ID,
    546         'Author_ID' => $post->post_author,
    547         'Date' => $post->post_date,
    548         'Content' => $post->post_content,
    549         'Excerpt' => $post->post_excerpt,
    550         'Title' => $post->post_title,
    551         'Category' => $post->post_category,
    552         'post_status' => $post->post_status,
    553         'comment_status' => $post->comment_status,
    554         'ping_status' => $post->ping_status,
    555         'post_password' => $post->post_password,
    556         'to_ping' => $post->to_ping,
    557         'pinged' => $post->pinged,
    558         'post_type' => $post->post_type,
    559         'post_name' => $post->post_name
    560     );
    561 
    562     return $postdata;
    563538}
    564539
     
    12511226}
    12521227
    1253 // Deprecated.  Use the new post loop.
    1254 function start_wp() {
    1255     global $wp_query, $post;
    1256 
    1257     // Since the old style loop is being used, advance the query iterator here.
    1258     $wp_query->next_post();
    1259 
    1260     setup_postdata($post);
    1261 }
    1262 
    12631228// Setup global post data.
    12641229function setup_postdata($post) {
  • 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
  • trunk/wp-includes/template-functions-category.php

    r3582 r3589  
    140140    }
    141141    return $chain;
    142 }
    143 
    144 // Deprecated.
    145 function the_category_ID($echo = true) {
    146     // Grab the first cat in the list.
    147     $categories = get_the_category();
    148     $cat = $categories[0]->cat_ID;
    149 
    150     if ( $echo )
    151         echo $cat;
    152 
    153     return $cat;
    154 }
    155 
    156 // Deprecated.
    157 function the_category_head($before='', $after='') {
    158     global $currentcat, $previouscat;
    159     // Grab the first cat in the list.
    160     $categories = get_the_category();
    161     $currentcat = $categories[0]->category_id;
    162     if ( $currentcat != $previouscat ) {
    163         echo $before;
    164         echo get_the_category_by_ID($currentcat);
    165         echo $after;
    166         $previouscat = $currentcat;
    167     }
    168142}
    169143
     
    385359}
    386360
    387 function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=FALSE, $child_of=0, $categories=0, $recurse=0, $feed = '', $feed_image = '', $exclude = '', $hierarchical=FALSE) {
    388     $query = "optionall=$optionall&all=$all&sort_column=$sort_column&sort_order=$sort_order&list=$list&optiondates=$optiondates&optioncount=$optioncount&hide_empty=$hide_empty&use_desc_for_title=$use_desc_for_title&child_of=$child_of&feed=$feed&feed_image=$feed_image&exclude=$exclude&hierarchical=$hierarchical";
    389     return wp_list_cats($query);
    390 }
    391 
    392361function in_category($category) { // Check if the current post is in the given category
    393362    global $category_cache, $post;
  • trunk/wp-includes/template-functions-links.php

    r3567 r3589  
    344344}
    345345
    346 
    347 // Deprecated.  Use previous_post_link().
    348 function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') {
    349 
    350     if ( empty($in_same_cat) || 'no' == $in_same_cat )
    351         $in_same_cat = false;
    352     else
    353         $in_same_cat = true;
    354 
    355     $post = get_previous_post($in_same_cat, $excluded_categories);
    356 
    357     if ( !$post )
    358         return;
    359 
    360     $string = '<a href="'.get_permalink($post->ID).'">'.$previous;
    361     if ( 'yes' == $title )
    362         $string .= apply_filters('the_title', $post->post_title, $post);
    363     $string .= '</a>';
    364     $format = str_replace('%', $string, $format);
    365     echo $format;
    366 }
    367 
    368 // Deprecated.  Use next_post_link().
    369 function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') {
    370 
    371     if ( empty($in_same_cat) || 'no' == $in_same_cat )
    372         $in_same_cat = false;
    373     else
    374         $in_same_cat = true;
    375 
    376     $post = get_next_post($in_same_cat, $excluded_categories);
    377 
    378     if ( !$post )
    379         return;
    380 
    381     $string = '<a href="'.get_permalink($post->ID).'">'.$next;
    382     if ( 'yes' == $title )
    383         $string .= apply_filters('the_title', $post->post_title, $nextpost);
    384     $string .= '</a>';
    385     $format = str_replace('%', $string, $format);
    386     echo $format;
    387 }
    388 
    389346function get_pagenum_link($pagenum = 1) {
    390347    global $wp_rewrite;
     
    536493}
    537494
     495// Deprecated.  Use previous_post_link().
     496function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') {
     497
     498    if ( empty($in_same_cat) || 'no' == $in_same_cat )
     499        $in_same_cat = false;
     500    else
     501        $in_same_cat = true;
     502
     503    $post = get_previous_post($in_same_cat, $excluded_categories);
     504
     505    if ( !$post )
     506        return;
     507
     508    $string = '<a href="'.get_permalink($post->ID).'">'.$previous;
     509    if ( 'yes' == $title )
     510        $string .= apply_filters('the_title', $post->post_title, $post);
     511    $string .= '</a>';
     512    $format = str_replace('%', $string, $format);
     513    echo $format;
     514}
     515
     516// Deprecated.  Use next_post_link().
     517function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') {
     518
     519    if ( empty($in_same_cat) || 'no' == $in_same_cat )
     520        $in_same_cat = false;
     521    else
     522        $in_same_cat = true;
     523
     524    $post = get_next_post($in_same_cat, $excluded_categories);
     525
     526    if ( !$post )
     527        return;
     528
     529    $string = '<a href="'.get_permalink($post->ID).'">'.$next;
     530    if ( 'yes' == $title )
     531        $string .= apply_filters('the_title', $post->post_title, $nextpost);
     532    $string .= '</a>';
     533    $format = str_replace('%', $string, $format);
     534    echo $format;
     535}
     536
    538537?>
  • trunk/wp-settings.php

    r3572 r3589  
    145145require (ABSPATH . WPINC . '/kses.php');
    146146require (ABSPATH . WPINC . '/version.php');
     147require (ABSPATH . WPINC . '/deprecated.php');
    147148
    148149if (!strstr($_SERVER['PHP_SELF'], 'install.php')) :
Note: See TracChangeset for help on using the changeset viewer.