[ XREF Home ] [ Index ]

PHP Cross Reference of WordPress Trunk

Provided by Yoast

title

Body

[close]

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

   1  <?php
   2  /**
   3   * Deprecated admin functions from past WordPress versions. You shouldn't use these
   4   * functions and look for the alternatives instead. The functions will be removed
   5   * in a later version.
   6   *
   7   * @package WordPress
   8   * @subpackage Deprecated
   9   */
  10  
  11  /*
  12   * Deprecated functions come here to die.
  13   */
  14  
  15  /**
  16   * @since 2.1
  17   * @deprecated 2.1
  18   * @deprecated Use wp_tiny_mce().
  19   * @see wp_tiny_mce()
  20   */
  21  function tinymce_include() {
  22      _deprecated_function( __FUNCTION__, '2.1', 'wp_tiny_mce()' );
  23  
  24      wp_tiny_mce();
  25  }
  26  
  27  /**
  28   * Unused Admin function.
  29   *
  30   * @since 2.0
  31   * @deprecated 2.5
  32   *
  33   */
  34  function documentation_link() {
  35      _deprecated_function( __FUNCTION__, '2.5' );
  36      return;
  37  }
  38  
  39  /**
  40   * Calculates the new dimentions for a downsampled image.
  41   *
  42   * @since 2.0.0
  43   * @deprecated 3.0.0
  44   * @deprecated Use wp_constrain_dimensions()
  45   *
  46   * @param int $width Current width of the image
  47   * @param int $height Current height of the image
  48   * @param int $wmax Maximum wanted width
  49   * @param int $hmax Maximum wanted height
  50   * @return mixed Array(height,width) of shrunk dimensions.
  51   */
  52  function wp_shrink_dimensions( $width, $height, $wmax = 128, $hmax = 96 ) {
  53      _deprecated_function( __FUNCTION__, '3.0', 'wp_constrain_dimensions()' );
  54      return wp_constrain_dimensions( $width, $height, $wmax, $hmax );
  55  }
  56  
  57  /**
  58   * {@internal Missing Short Description}}
  59   *
  60   * @since 0.71
  61   * @deprecated 2.6.0
  62   * @deprecated Use wp_category_checklist()
  63   * @see wp_category_checklist()
  64   *
  65   * @param unknown_type $default
  66   * @param unknown_type $parent
  67   * @param unknown_type $popular_ids
  68   */
  69  function dropdown_categories( $default = 0, $parent = 0, $popular_ids = array() ) {
  70      _deprecated_function( __FUNCTION__, '2.6', 'wp_category_checklist()' );
  71      global $post_ID;
  72      wp_category_checklist( $post_ID );
  73  }
  74  
  75  /**
  76   * {@internal Missing Short Description}}
  77   *
  78   * @since 2.1.0
  79   * @deprecated 2.6.0
  80   * @deprecated Use wp_link_category_checklist()
  81   * @see wp_link_category_checklist()
  82   *
  83   * @param unknown_type $default
  84   */
  85  function dropdown_link_categories( $default = 0 ) {
  86      _deprecated_function( __FUNCTION__, '2.6', 'wp_link_category_checklist()' );
  87      global $link_id;
  88      wp_link_category_checklist( $link_id );
  89  }
  90  
  91  /**
  92   * {@internal Missing Short Description}}
  93   *
  94   * @since 1.2.0
  95   * @deprecated 3.0.0
  96   * @deprecated Use wp_dropdown_categories()
  97   * @see wp_dropdown_categories()
  98   *
  99   * @param unknown_type $currentcat
 100   * @param unknown_type $currentparent
 101   * @param unknown_type $parent
 102   * @param unknown_type $level
 103   * @param unknown_type $categories
 104   * @return unknown
 105   */
 106  function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) {
 107      _deprecated_function( __FUNCTION__, '3.0', 'wp_dropdown_categories()' );
 108      if (!$categories )
 109          $categories = get_categories( array('hide_empty' => 0) );
 110  
 111      if ( $categories ) {
 112          foreach ( $categories as $category ) {
 113              if ( $currentcat != $category->term_id && $parent == $category->parent) {
 114                  $pad = str_repeat( '&#8211; ', $level );
 115                  $category->name = esc_html( $category->name );
 116                  echo "\n\t<option value='$category->term_id'";
 117                  if ( $currentparent == $category->term_id )
 118                      echo " selected='selected'";
 119                  echo ">$pad$category->name</option>";
 120                  wp_dropdown_cats( $currentcat, $currentparent, $category->term_id, $level +1, $categories );
 121              }
 122          }
 123      } else {
 124          return false;
 125      }
 126  }
 127  
 128  /**
 129   * Register a setting and its sanitization callback
 130   *
 131   * @since 2.7.0
 132   * @deprecated 3.0.0
 133   * @deprecated Use register_setting()
 134   * @see register_setting()
 135   *
 136   * @param string $option_group A settings group name.  Should correspond to a whitelisted option key name.
 137   *     Default whitelisted option key names include "general," "discussion," and "reading," among others.
 138   * @param string $option_name The name of an option to sanitize and save.
 139   * @param unknown_type $sanitize_callback A callback function that sanitizes the option's value.
 140   * @return unknown
 141   */
 142  function add_option_update_handler( $option_group, $option_name, $sanitize_callback = '' ) {
 143      _deprecated_function( __FUNCTION__, '3.0', 'register_setting()' );
 144      return register_setting( $option_group, $option_name, $sanitize_callback );
 145  }
 146  
 147  /**
 148   * Unregister a setting
 149   *
 150   * @since 2.7.0
 151   * @deprecated 3.0.0
 152   * @deprecated Use unregister_setting()
 153   * @see unregister_setting()
 154   *
 155   * @param unknown_type $option_group
 156   * @param unknown_type $option_name
 157   * @param unknown_type $sanitize_callback
 158   * @return unknown
 159   */
 160  function remove_option_update_handler( $option_group, $option_name, $sanitize_callback = '' ) {
 161      _deprecated_function( __FUNCTION__, '3.0', 'unregister_setting()' );
 162      return unregister_setting( $option_group, $option_name, $sanitize_callback );
 163  }
 164  
 165  /**
 166   * Determines the language to use for CodePress syntax highlighting.
 167   *
 168   * @since 2.8.0
 169   * @deprecated 3.0.0
 170   *
 171   * @param string $filename
 172  **/
 173  function codepress_get_lang( $filename ) {
 174      _deprecated_function( __FUNCTION__, '3.0' );
 175      return;
 176  }
 177  
 178  /**
 179   * Adds Javascript required to make CodePress work on the theme/plugin editors.
 180   *
 181   * @since 2.8.0
 182   * @deprecated 3.0.0
 183  **/
 184  function codepress_footer_js() {
 185      _deprecated_function( __FUNCTION__, '3.0' );
 186      return;
 187  }
 188  
 189  /**
 190   * Determine whether to use CodePress.
 191   *
 192   * @since 2.8
 193   * @deprecated 3.0.0
 194  **/
 195  function use_codepress() {
 196      _deprecated_function( __FUNCTION__, '3.0' );
 197      return;
 198  }
 199  
 200  
 201  /**
 202   * @deprecated 3.1.0
 203   *
 204   * @return array List of user IDs.
 205   */
 206  function get_author_user_ids() {
 207      _deprecated_function( __FUNCTION__, '3.1', 'get_users()' );
 208  
 209      global $wpdb;
 210      if ( !is_multisite() )
 211          $level_key = $wpdb->get_blog_prefix() . 'user_level';
 212      else
 213          $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
 214  
 215      return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != '0'", $level_key) );
 216  }
 217  
 218  /**
 219   * @deprecated 3.1.0
 220   *
 221   * @param int $user_id User ID.
 222   * @return array|bool List of editable authors. False if no editable users.
 223   */
 224  function get_editable_authors( $user_id ) {
 225      _deprecated_function( __FUNCTION__, '3.1', 'get_users()' );
 226  
 227      global $wpdb;
 228  
 229      $editable = get_editable_user_ids( $user_id );
 230  
 231      if ( !$editable ) {
 232          return false;
 233      } else {
 234          $editable = join(',', $editable);
 235          $authors = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($editable) ORDER BY display_name" );
 236      }
 237  
 238      return apply_filters('get_editable_authors', $authors);
 239  }
 240  
 241  /**
 242   * @deprecated 3.1.0
 243   *
 244   * @param int $user_id User ID.
 245   * @param bool $exclude_zeros Optional, default is true. Whether to exclude zeros.
 246   * @return unknown
 247   */
 248  function get_editable_user_ids( $user_id, $exclude_zeros = true, $post_type = 'post' ) {
 249      _deprecated_function( __FUNCTION__, '3.1', 'get_users()' );
 250  
 251      global $wpdb;
 252  
 253      $user = new WP_User( $user_id );
 254      $post_type_obj = get_post_type_object($post_type);
 255  
 256      if ( ! $user->has_cap($post_type_obj->cap->edit_others_posts) ) {
 257          if ( $user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros )
 258              return array($user->id);
 259          else
 260              return array();
 261      }
 262  
 263      if ( !is_multisite() )
 264          $level_key = $wpdb->get_blog_prefix() . 'user_level';
 265      else
 266          $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
 267  
 268      $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s", $level_key);
 269      if ( $exclude_zeros )
 270          $query .= " AND meta_value != '0'";
 271  
 272      return $wpdb->get_col( $query );
 273  }
 274  
 275  /**
 276   * @deprecated 3.1.0
 277   */
 278  function get_nonauthor_user_ids() {
 279      _deprecated_function( __FUNCTION__, '3.1', 'get_users()' );
 280  
 281      global $wpdb;
 282  
 283      if ( !is_multisite() )
 284          $level_key = $wpdb->get_blog_prefix() . 'user_level';
 285      else
 286          $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
 287  
 288      return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) );
 289  }
 290  
 291  if ( !class_exists('WP_User_Search') ) :
 292  /**
 293   * WordPress User Search class.
 294   *
 295   * @since 2.1.0
 296   * @deprecated 3.1.0
 297   */
 298  class WP_User_Search {
 299  
 300      /**
 301       * {@internal Missing Description}}
 302       *
 303       * @since 2.1.0
 304       * @access private
 305       * @var unknown_type
 306       */
 307      var $results;
 308  
 309      /**
 310       * {@internal Missing Description}}
 311       *
 312       * @since 2.1.0
 313       * @access private
 314       * @var unknown_type
 315       */
 316      var $search_term;
 317  
 318      /**
 319       * Page number.
 320       *
 321       * @since 2.1.0
 322       * @access private
 323       * @var int
 324       */
 325      var $page;
 326  
 327      /**
 328       * Role name that users have.
 329       *
 330       * @since 2.5.0
 331       * @access private
 332       * @var string
 333       */
 334      var $role;
 335  
 336      /**
 337       * Raw page number.
 338       *
 339       * @since 2.1.0
 340       * @access private
 341       * @var int|bool
 342       */
 343      var $raw_page;
 344  
 345      /**
 346       * Amount of users to display per page.
 347       *
 348       * @since 2.1.0
 349       * @access public
 350       * @var int
 351       */
 352      var $users_per_page = 50;
 353  
 354      /**
 355       * {@internal Missing Description}}
 356       *
 357       * @since 2.1.0
 358       * @access private
 359       * @var unknown_type
 360       */
 361      var $first_user;
 362  
 363      /**
 364       * {@internal Missing Description}}
 365       *
 366       * @since 2.1.0
 367       * @access private
 368       * @var int
 369       */
 370      var $last_user;
 371  
 372      /**
 373       * {@internal Missing Description}}
 374       *
 375       * @since 2.1.0
 376       * @access private
 377       * @var string
 378       */
 379      var $query_limit;
 380  
 381      /**
 382       * {@internal Missing Description}}
 383       *
 384       * @since 3.0.0
 385       * @access private
 386       * @var string
 387       */
 388      var $query_orderby;
 389  
 390      /**
 391       * {@internal Missing Description}}
 392       *
 393       * @since 3.0.0
 394       * @access private
 395       * @var string
 396       */
 397      var $query_from;
 398  
 399      /**
 400       * {@internal Missing Description}}
 401       *
 402       * @since 3.0.0
 403       * @access private
 404       * @var string
 405       */
 406      var $query_where;
 407  
 408      /**
 409       * {@internal Missing Description}}
 410       *
 411       * @since 2.1.0
 412       * @access private
 413       * @var int
 414       */
 415      var $total_users_for_query = 0;
 416  
 417      /**
 418       * {@internal Missing Description}}
 419       *
 420       * @since 2.1.0
 421       * @access private
 422       * @var bool
 423       */
 424      var $too_many_total_users = false;
 425  
 426      /**
 427       * {@internal Missing Description}}
 428       *
 429       * @since 2.1.0
 430       * @access private
 431       * @var unknown_type
 432       */
 433      var $search_errors;
 434  
 435      /**
 436       * {@internal Missing Description}}
 437       *
 438       * @since 2.7.0
 439       * @access private
 440       * @var unknown_type
 441       */
 442      var $paging_text;
 443  
 444      /**
 445       * PHP4 Constructor - Sets up the object properties.
 446       *
 447       * @since 2.1.0
 448       *
 449       * @param string $search_term Search terms string.
 450       * @param int $page Optional. Page ID.
 451       * @param string $role Role name.
 452       * @return WP_User_Search
 453       */
 454  	function WP_User_Search ($search_term = '', $page = '', $role = '') {
 455          _deprecated_function( __FUNCTION__, '3.1', 'WP_User_Query' );
 456  
 457          $this->search_term = $search_term;
 458          $this->raw_page = ( '' == $page ) ? false : (int) $page;
 459          $this->page = (int) ( '' == $page ) ? 1 : $page;
 460          $this->role = $role;
 461  
 462          $this->prepare_query();
 463          $this->query();
 464          $this->prepare_vars_for_template_usage();
 465          $this->do_paging();
 466      }
 467  
 468      /**
 469       * {@internal Missing Short Description}}
 470       *
 471       * {@internal Missing Long Description}}
 472       *
 473       * @since 2.1.0
 474       * @access public
 475       */
 476  	function prepare_query() {
 477          global $wpdb;
 478          $this->first_user = ($this->page - 1) * $this->users_per_page;
 479  
 480          $this->query_limit = $wpdb->prepare(" LIMIT %d, %d", $this->first_user, $this->users_per_page);
 481          $this->query_orderby = ' ORDER BY user_login';
 482  
 483          $search_sql = '';
 484          if ( $this->search_term ) {
 485              $searches = array();
 486              $search_sql = 'AND (';
 487              foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col )
 488                  $searches[] = $col . " LIKE '%$this->search_term%'";
 489              $search_sql .= implode(' OR ', $searches);
 490              $search_sql .= ')';
 491          }
 492  
 493          $this->query_from = " FROM $wpdb->users";
 494          $this->query_where = " WHERE 1=1 $search_sql";
 495  
 496          if ( $this->role ) {
 497              $this->query_from .= " INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id";
 498              $this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%');
 499          } elseif ( is_multisite() ) {
 500              $level_key = $wpdb->prefix . 'capabilities'; // wpmu site admins don't have user_levels
 501              $this->query_from .= ", $wpdb->usermeta";
 502              $this->query_where .= " AND $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '{$level_key}'";
 503          }
 504  
 505          do_action_ref_array( 'pre_user_search', array( &$this ) );
 506      }
 507  
 508      /**
 509       * {@internal Missing Short Description}}
 510       *
 511       * {@internal Missing Long Description}}
 512       *
 513       * @since 2.1.0
 514       * @access public
 515       */
 516  	function query() {
 517          global $wpdb;
 518  
 519          $this->results = $wpdb->get_col("SELECT DISTINCT($wpdb->users.ID)" . $this->query_from . $this->query_where . $this->query_orderby . $this->query_limit);
 520  
 521          if ( $this->results )
 522              $this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where); // no limit
 523          else
 524              $this->search_errors = new WP_Error('no_matching_users_found', __('No matching users were found!'));
 525      }
 526  
 527      /**
 528       * {@internal Missing Short Description}}
 529       *
 530       * {@internal Missing Long Description}}
 531       *
 532       * @since 2.1.0
 533       * @access public
 534       */
 535  	function prepare_vars_for_template_usage() {
 536          $this->search_term = stripslashes($this->search_term); // done with DB, from now on we want slashes gone
 537      }
 538  
 539      /**
 540       * {@internal Missing Short Description}}
 541       *
 542       * {@internal Missing Long Description}}
 543       *
 544       * @since 2.1.0
 545       * @access public
 546       */
 547  	function do_paging() {
 548          if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results
 549              $args = array();
 550              if( ! empty($this->search_term) )
 551                  $args['usersearch'] = urlencode($this->search_term);
 552              if( ! empty($this->role) )
 553                  $args['role'] = urlencode($this->role);
 554  
 555              $this->paging_text = paginate_links( array(
 556                  'total' => ceil($this->total_users_for_query / $this->users_per_page),
 557                  'current' => $this->page,
 558                  'base' => 'users.php?%_%',
 559                  'format' => 'userspage=%#%',
 560                  'add_args' => $args
 561              ) );
 562              if ( $this->paging_text ) {
 563                  $this->paging_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s',
 564                      number_format_i18n( ( $this->page - 1 ) * $this->users_per_page + 1 ),
 565                      number_format_i18n( min( $this->page * $this->users_per_page, $this->total_users_for_query ) ),
 566                      number_format_i18n( $this->total_users_for_query ),
 567                      $this->paging_text
 568                  );
 569              }
 570          }
 571      }
 572  
 573      /**
 574       * {@internal Missing Short Description}}
 575       *
 576       * {@internal Missing Long Description}}
 577       *
 578       * @since 2.1.0
 579       * @access public
 580       *
 581       * @return unknown
 582       */
 583  	function get_results() {
 584          return (array) $this->results;
 585      }
 586  
 587      /**
 588       * Displaying paging text.
 589       *
 590       * @see do_paging() Builds paging text.
 591       *
 592       * @since 2.1.0
 593       * @access public
 594       */
 595  	function page_links() {
 596          echo $this->paging_text;
 597      }
 598  
 599      /**
 600       * Whether paging is enabled.
 601       *
 602       * @see do_paging() Builds paging text.
 603       *
 604       * @since 2.1.0
 605       * @access public
 606       *
 607       * @return bool
 608       */
 609  	function results_are_paged() {
 610          if ( $this->paging_text )
 611              return true;
 612          return false;
 613      }
 614  
 615      /**
 616       * Whether there are search terms.
 617       *
 618       * @since 2.1.0
 619       * @access public
 620       *
 621       * @return bool
 622       */
 623  	function is_search() {
 624          if ( $this->search_term )
 625              return true;
 626          return false;
 627      }
 628  }
 629  endif;
 630  
 631  /**
 632   * Retrieve editable posts from other users.
 633   *
 634   * @deprecated 3.1.0
 635   *
 636   * @param int $user_id User ID to not retrieve posts from.
 637   * @param string $type Optional, defaults to 'any'. Post type to retrieve, can be 'draft' or 'pending'.
 638   * @return array List of posts from others.
 639   */
 640  function get_others_unpublished_posts($user_id, $type='any') {
 641      _deprecated_function( __FUNCTION__, '3.1' );
 642  
 643      global $wpdb;
 644  
 645      $editable = get_editable_user_ids( $user_id );
 646  
 647      if ( in_array($type, array('draft', 'pending')) )
 648          $type_sql = " post_status = '$type' ";
 649      else
 650          $type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) ";
 651  
 652      $dir = ( 'pending' == $type ) ? 'ASC' : 'DESC';
 653  
 654      if ( !$editable ) {
 655          $other_unpubs = '';
 656      } else {
 657          $editable = join(',', $editable);
 658          $other_unpubs = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_title, post_author FROM $wpdb->posts WHERE post_type = 'post' AND $type_sql AND post_author IN ($editable) AND post_author != %d ORDER BY post_modified $dir", $user_id) );
 659      }
 660  
 661      return apply_filters('get_others_drafts', $other_unpubs);
 662  }
 663  
 664  /**
 665   * Retrieve drafts from other users.
 666   *
 667   * @deprecated 3.1.0
 668   *
 669   * @param int $user_id User ID.
 670   * @return array List of drafts from other users.
 671   */
 672  function get_others_drafts($user_id) {
 673      _deprecated_function( __FUNCTION__, '3.1' );
 674  
 675      return get_others_unpublished_posts($user_id, 'draft');
 676  }
 677  
 678  /**
 679   * Retrieve pending review posts from other users.
 680   *
 681   * @deprecated 3.1.0
 682   *
 683   * @param int $user_id User ID.
 684   * @return array List of posts with pending review post type from other users.
 685   */
 686  function get_others_pending($user_id) {
 687      _deprecated_function( __FUNCTION__, '3.1' );
 688  
 689      return get_others_unpublished_posts($user_id, 'pending');
 690  }
 691  
 692  /**
 693   * Output the QuickPress dashboard widget.
 694   *
 695   * @since 3.0.0
 696   * @deprecated 3.2.0
 697   * @deprecated Use wp_dashboard_quick_press()
 698   * @see wp_dashboard_quick_press()
 699   */
 700  function wp_dashboard_quick_press_output() {
 701      _deprecated_function( __FUNCTION__, '3.2', 'wp_dashboard_quick_press()' );
 702      wp_dashboard_quick_press();
 703  }


Generated: Wed Jun 1 08:30:02 2011 Cross-referenced by PHPXref 0.7
Provided by Yoast and awesome WordPress Hosting