[ Index ]

WordPress Source Cross Reference

title

Body

[close]

/wp-includes/ -> deprecated.php (source)

   1  <?php
   2  /*
   3   * Deprecated functios come here to die.
   4   */
   5  
   6  // Deprecated.  Use get_post().
   7  function get_postdata($postid) {
   8      $post = &get_post($postid);
   9  
  10      $postdata = array (
  11          'ID' => $post->ID,
  12          'Author_ID' => $post->post_author,
  13          'Date' => $post->post_date,
  14          'Content' => $post->post_content,
  15          'Excerpt' => $post->post_excerpt,
  16          'Title' => $post->post_title,
  17          'Category' => $post->post_category,
  18          'post_status' => $post->post_status,
  19          'comment_status' => $post->comment_status,
  20          'ping_status' => $post->ping_status,
  21          'post_password' => $post->post_password,
  22          'to_ping' => $post->to_ping,
  23          'pinged' => $post->pinged,
  24          'post_type' => $post->post_type,
  25          'post_name' => $post->post_name
  26      );
  27  
  28      return $postdata;
  29  }
  30  
  31  // Deprecated.  Use the new post loop.
  32  function start_wp() {
  33      global $wp_query, $post;
  34  
  35      // Since the old style loop is being used, advance the query iterator here.
  36      $wp_query->next_post();
  37  
  38      setup_postdata($post);
  39  }
  40  
  41  // Deprecated.
  42  function the_category_ID($echo = true) {
  43      // Grab the first cat in the list.
  44      $categories = get_the_category();
  45      $cat = $categories[0]->cat_ID;
  46  
  47      if ( $echo )
  48          echo $cat;
  49  
  50      return $cat;
  51  }
  52  
  53  // Deprecated.
  54  function the_category_head($before='', $after='') {
  55      global $currentcat, $previouscat;
  56      // Grab the first cat in the list.
  57      $categories = get_the_category();
  58      $currentcat = $categories[0]->category_id;
  59      if ( $currentcat != $previouscat ) {
  60          echo $before;
  61          echo get_the_category_by_ID($currentcat);
  62          echo $after;
  63          $previouscat = $currentcat;
  64      }
  65  }
  66  
  67  // Deprecated.    Use previous_post_link().
  68  function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') {
  69  
  70      if ( empty($in_same_cat) || 'no' == $in_same_cat )
  71          $in_same_cat = false;
  72      else
  73          $in_same_cat = true;
  74  
  75      $post = get_previous_post($in_same_cat, $excluded_categories);
  76  
  77      if ( !$post )
  78          return;
  79  
  80      $string = '<a href="'.get_permalink($post->ID).'">'.$previous;
  81      if ( 'yes' == $title )
  82          $string .= apply_filters('the_title', $post->post_title, $post);
  83      $string .= '</a>';
  84      $format = str_replace('%', $string, $format);
  85      echo $format;
  86  }
  87  
  88  // Deprecated.    Use next_post_link().
  89  function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') {
  90  
  91      if ( empty($in_same_cat) || 'no' == $in_same_cat )
  92          $in_same_cat = false;
  93      else
  94          $in_same_cat = true;
  95  
  96      $post = get_next_post($in_same_cat, $excluded_categories);
  97  
  98      if ( !$post    )
  99          return;
 100  
 101      $string = '<a href="'.get_permalink($post->ID).'">'.$next;
 102      if ( 'yes' == $title )
 103          $string .= apply_filters('the_title', $post->post_title, $nextpost);
 104      $string .= '</a>';
 105      $format = str_replace('%', $string, $format);
 106      echo $format;
 107  }
 108  
 109  //
 110  // These are deprecated.  Use current_user_can().
 111  //
 112  
 113  /* returns true if $user_id can create a new post */
 114  function user_can_create_post($user_id, $blog_id = 1, $category_id = 'None') {
 115      $author_data = get_userdata($user_id);
 116      return ($author_data->user_level > 1);
 117  }
 118  
 119  /* returns true if $user_id can create a new post */
 120  function user_can_create_draft($user_id, $blog_id = 1, $category_id = 'None') {
 121      $author_data = get_userdata($user_id);
 122      return ($author_data->user_level >= 1);
 123  }
 124  
 125  /* returns true if $user_id can edit $post_id */
 126  function user_can_edit_post($user_id, $post_id, $blog_id = 1) {
 127      $author_data = get_userdata($user_id);
 128      $post = get_post($post_id);
 129      $post_author_data = get_userdata($post->post_author);
 130  
 131      if ( (($user_id == $post_author_data->ID) && !($post->post_status == 'publish' &&  $author_data->user_level < 2))
 132           || ($author_data->user_level > $post_author_data->user_level)
 133           || ($author_data->user_level >= 10) ) {
 134          return true;
 135      } else {
 136          return false;
 137      }
 138  }
 139  
 140  /* returns true if $user_id can delete $post_id */
 141  function user_can_delete_post($user_id, $post_id, $blog_id = 1) {
 142      // right now if one can edit, one can delete
 143      return user_can_edit_post($user_id, $post_id, $blog_id);
 144  }
 145  
 146  /* returns true if $user_id can set new posts' dates on $blog_id */
 147  function user_can_set_post_date($user_id, $blog_id = 1, $category_id = 'None') {
 148      $author_data = get_userdata($user_id);
 149      return (($author_data->user_level > 4) && user_can_create_post($user_id, $blog_id, $category_id));
 150  }
 151  
 152  /* returns true if $user_id can edit $post_id's date */
 153  function user_can_edit_post_date($user_id, $post_id, $blog_id = 1) {
 154      $author_data = get_userdata($user_id);
 155      return (($author_data->user_level > 4) && user_can_edit_post($user_id, $post_id, $blog_id));
 156  }
 157  
 158  /* returns true if $user_id can edit $post_id's comments */
 159  function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1) {
 160      // right now if one can edit a post, one can edit comments made on it
 161      return user_can_edit_post($user_id, $post_id, $blog_id);
 162  }
 163  
 164  /* returns true if $user_id can delete $post_id's comments */
 165  function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1) {
 166      // right now if one can edit comments, one can delete comments
 167      return user_can_edit_post_comments($user_id, $post_id, $blog_id);
 168  }
 169  
 170  function user_can_edit_user($user_id, $other_user) {
 171      $user  = get_userdata($user_id);
 172      $other = get_userdata($other_user);
 173      if ( $user->user_level > $other->user_level || $user->user_level > 8 || $user->ID == $other->ID )
 174          return true;
 175      else
 176          return false;
 177  }
 178  
 179  /** function get_linksbyname()
 180   ** Gets the links associated with category 'cat_name'.
 181   ** Parameters:
 182   **   cat_name (default 'noname')  - The category name to use. If no
 183   **     match is found uses all
 184   **   before (default '')  - the html to output before the link
 185   **   after (default '<br />')  - the html to output after the link
 186   **   between (default ' ')  - the html to output between the link/image
 187   **     and it's description. Not used if no image or show_images == true
 188   **   show_images (default true) - whether to show images (if defined).
 189   **   orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
 190   **     'url', 'description' or 'rating'. Or maybe owner. If you start the
 191   **     name with an underscore the order will be reversed.
 192   **     You can also specify 'rand' as the order which will return links in a
 193   **     random order.
 194   **   show_description (default true) - whether to show the description if
 195   **     show_images=false/not defined
 196   **   show_rating (default false) - show rating stars/chars
 197   **   limit (default -1) - Limit to X entries. If not specified, all entries
 198   **     are shown.
 199   **   show_updated (default 0) - whether to show last updated timestamp
 200   */
 201  function get_linksbyname($cat_name = "noname", $before = '', $after = '<br />',
 202                           $between = " ", $show_images = true, $orderby = 'id',
 203                           $show_description = true, $show_rating = false,
 204                           $limit = -1, $show_updated = 0) {
 205      global $wpdb;
 206      $cat_id = -1;
 207      $results = $wpdb->get_results("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$cat_name'");
 208      if ($results) {
 209          foreach ($results as $result) {
 210              $cat_id = $result->cat_ID;
 211          }
 212      }
 213      get_links($cat_id, $before, $after, $between, $show_images, $orderby,
 214                $show_description, $show_rating, $limit, $show_updated);
 215  }
 216  
 217  /** function wp_get_linksbyname()
 218   ** Gets the links associated with the named category.
 219   ** Parameters:
 220   **   category (no default)  - The category to use.
 221   **/
 222  function wp_get_linksbyname($category, $args = '') {
 223      global $wpdb;
 224  
 225      $cat_id = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$category' LIMIT 1");
 226  
 227      if (! $cat_id)
 228          return;
 229  
 230      $args = add_query_arg('category', $cat_id, $args);
 231      wp_get_links($args);
 232  } // end wp_get_linksbyname
 233  
 234  /** function get_linkobjectsbyname()
 235   ** Gets an array of link objects associated with category 'cat_name'.
 236   ** Parameters:
 237   **   cat_name (default 'noname')  - The category name to use. If no
 238   **     match is found uses all
 239   **   orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
 240   **     'url', 'description', or 'rating'. Or maybe owner. If you start the
 241   **     name with an underscore the order will be reversed.
 242   **     You can also specify 'rand' as the order which will return links in a
 243   **     random order.
 244   **   limit (default -1) - Limit to X entries. If not specified, all entries
 245   **     are shown.
 246   **
 247   ** Use this like:
 248   ** $links = get_linkobjectsbyname('fred');
 249   ** foreach ($links as $link) {
 250   **   echo '<li>'.$link->link_name.'</li>';
 251   ** }
 252   **/
 253  // Deprecate in favor of get_linkz().
 254  function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) {
 255      global $wpdb;
 256      $cat_id = -1;
 257      //$results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'");
 258      // TODO: Fix me.
 259      if ($results) {
 260          foreach ($results as $result) {
 261              $cat_id = $result->cat_id;
 262          }
 263      }
 264      return get_linkobjects($cat_id, $orderby, $limit);
 265  }
 266  
 267  /** function get_linkobjects()
 268   ** Gets an array of link objects associated with category n.
 269   ** Parameters:
 270   **   category (default -1)  - The category to use. If no category supplied
 271   **      uses all
 272   **   orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
 273   **     'url', 'description', or 'rating'. Or maybe owner. If you start the
 274   **     name with an underscore the order will be reversed.
 275   **     You can also specify 'rand' as the order which will return links in a
 276   **     random order.
 277   **   limit (default -1) - Limit to X entries. If not specified, all entries
 278   **     are shown.
 279   **
 280   ** Use this like:
 281   ** $links = get_linkobjects(1);
 282   ** if ($links) {
 283   **   foreach ($links as $link) {
 284   **     echo '<li>'.$link->link_name.'<br />'.$link->link_description.'</li>';
 285   **   }
 286   ** }
 287   ** Fields are:
 288   ** link_id
 289   ** link_url
 290   ** link_name
 291   ** link_image
 292   ** link_target
 293   ** link_category
 294   ** link_description
 295   ** link_visible
 296   ** link_owner
 297   ** link_rating
 298   ** link_updated
 299   ** link_rel
 300   ** link_notes
 301   **/
 302  // Deprecate in favor of get_linkz().
 303  function get_linkobjects($category = -1, $orderby = 'name', $limit = -1) {
 304      global $wpdb;
 305  
 306      $sql = "SELECT * FROM $wpdb->links WHERE link_visible = 'Y'";
 307      if ($category != -1) {
 308          $sql .= " AND link_category = $category ";
 309      }
 310      if ($orderby == '')
 311          $orderby = 'id';
 312      if (substr($orderby,0,1) == '_') {
 313          $direction = ' DESC';
 314          $orderby = substr($orderby,1);
 315      }
 316      if (strcasecmp('rand',$orderby) == 0) {
 317          $orderby = 'rand()';
 318      } else {
 319          $orderby = " link_" . $orderby;
 320      }
 321      $sql .= ' ORDER BY ' . $orderby;
 322      $sql .= $direction;
 323      /* The next 2 lines implement LIMIT TO processing */
 324      if ($limit != -1)
 325          $sql .= " LIMIT $limit";
 326  
 327      $results = $wpdb->get_results($sql);
 328      if ($results) {
 329          foreach ($results as $result) {
 330              $result->link_url         = $result->link_url;
 331              $result->link_name        = $result->link_name;
 332              $result->link_description = $result->link_description;
 333              $result->link_notes       = $result->link_notes;
 334              $newresults[] = $result;
 335          }
 336      }
 337      return $newresults;
 338  }
 339  
 340  /** function get_linksbyname_withrating()
 341   ** Gets the links associated with category 'cat_name' and display rating stars/chars.
 342   ** Parameters:
 343   **   cat_name (default 'noname')  - The category name to use. If no
 344   **     match is found uses all
 345   **   before (default '')  - the html to output before the link
 346   **   after (default '<br />')  - the html to output after the link
 347   **   between (default ' ')  - the html to output between the link/image
 348   **     and it's description. Not used if no image or show_images == true
 349   **   show_images (default true) - whether to show images (if defined).
 350   **   orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
 351   **     'url' or 'description'. Or maybe owner. If you start the
 352   **     name with an underscore the order will be reversed.
 353   **     You can also specify 'rand' as the order which will return links in a
 354   **     random order.
 355   **   show_description (default true) - whether to show the description if
 356   **     show_images=false/not defined
 357   **   limit (default -1) - Limit to X entries. If not specified, all entries
 358   **     are shown.
 359   **   show_updated (default 0) - whether to show last updated timestamp
 360   */
 361  function get_linksbyname_withrating($cat_name = "noname", $before = '',
 362                                      $after = '<br />', $between = " ",
 363                                      $show_images = true, $orderby = 'id',
 364                                      $show_description = true, $limit = -1, $show_updated = 0) {
 365  
 366      get_linksbyname($cat_name, $before, $after, $between, $show_images,
 367                      $orderby, $show_description, true, $limit, $show_updated);
 368  }
 369  
 370  /** function get_links_withrating()
 371   ** Gets the links associated with category n and display rating stars/chars.
 372   ** Parameters:
 373   **   category (default -1)  - The category to use. If no category supplied
 374   **      uses all
 375   **   before (default '')  - the html to output before the link
 376   **   after (default '<br />')  - the html to output after the link
 377   **   between (default ' ')  - the html to output between the link/image
 378   **     and it's description. Not used if no image or show_images == true
 379   **   show_images (default true) - whether to show images (if defined).
 380   **   orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
 381   **     'url' or 'description'. Or maybe owner. If you start the
 382   **     name with an underscore the order will be reversed.
 383   **     You can also specify 'rand' as the order which will return links in a
 384   **     random order.
 385   **   show_description (default true) - whether to show the description if
 386   **    show_images=false/not defined .
 387   **   limit (default -1) - Limit to X entries. If not specified, all entries
 388   **     are shown.
 389   **   show_updated (default 0) - whether to show last updated timestamp
 390   */
 391  function get_links_withrating($category = -1, $before = '', $after = '<br />',
 392                                $between = " ", $show_images = true,
 393                                $orderby = 'id', $show_description = true,
 394                                $limit = -1, $show_updated = 0) {
 395  
 396      get_links($category, $before, $after, $between, $show_images, $orderby,
 397                $show_description, true, $limit, $show_updated);
 398  }
 399  
 400  /** function get_get_autotoggle()
 401   ** Gets the auto_toggle setting of category n.
 402   ** Parameters: id (default 0)  - The category to get. If no category supplied
 403   **                uses 0
 404   */
 405  function get_autotoggle($id = 0) {
 406      return 0;  
 407  }
 408  
 409  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) {
 410      $query = compact('optionall', 'all', 'sort_column', 'sort_order', 'file', 'list', 'optiondates', 'optioncount', 'hide_empty', 'use_desc_for_title', 'children',
 411          'child_of', 'categories', 'recurse', 'feed', 'feed_image', 'exclude', 'hierarchical');
 412      return wp_list_cats($query);
 413  }
 414  
 415  function wp_list_cats($args = '') {
 416      if ( is_array($args) )
 417          $r = &$args;
 418      else
 419          parse_str($args, $r);
 420  
 421      // Map to new names.
 422      if ( isset($r['optionall']) && isset($r['all']))
 423          $r['show_option_all'] = $r['all'];
 424      if ( isset($r['sort_column']) )
 425          $r['orderby'] = $r['sort_column'];
 426      if ( isset($r['sort_order']) )
 427          $r['order'] = $r['sort_order'];
 428      if ( isset($r['optiondates']) )
 429          $r['show_last_update'] = $r['optiondates'];
 430      if ( isset($r['optioncount']) )
 431          $r['show_count'] = $r['optioncount'];
 432      if ( !empty($r['list']) )
 433          $r['style'] = 'break';
 434      $r['title_li'] = '';
 435  
 436      return wp_list_categories($r);    
 437  }
 438  
 439  function dropdown_cats($optionall = 1, $all = 'All', $orderby = 'ID', $order = 'asc',
 440          $show_last_update = 0, $show_count = 0, $hide_empty = 1, $optionnone = FALSE,
 441          $selected = 0, $exclude = 0) {
 442  
 443      $show_option_all = '';
 444      if ( $optionall )
 445          $show_option_all = $all;
 446  
 447      $show_option_none = '';
 448      if ( $optionnone )
 449          $show_option_none = __('None');
 450  
 451      $vars = compact('show_option_all', 'show_option_none', 'orderby', 'order',
 452                      'show_last_update', 'show_count', 'hide_empty', 'selected', 'exclude');
 453      $query = add_query_arg($vars, '');
 454      return wp_dropdown_categories($query);
 455  }
 456  
 457  // Deprecated.  Use wp_print_scripts() or WP_Scripts instead.
 458  function tinymce_include() {
 459      wp_print_script( 'wp_tiny_mce' );
 460  }
 461  
 462  function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') {
 463      $args = compact('optioncount', 'exclude_admin', 'show_fullname', 'hide_empty', 'feed', 'feed_image');
 464      return wp_list_authors($args);
 465  }
 466  
 467  function wp_get_post_cats($blogid = '1', $post_ID = 0) {
 468      return wp_get_post_categories($post_ID);
 469  }
 470  
 471  function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array()) {
 472      return wp_set_post_categories($post_ID, $post_categories);
 473  }
 474  
 475  function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) {
 476      $args = compact('type', 'limit', 'format', 'before', 'after', 'show_post_count');
 477      return wp_get_archives($args);
 478  }
 479  
 480  ?>