Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/deprecated.php

    r17293 r14718  
    3333 */
    3434function documentation_link() {
    35     _deprecated_function( __FUNCTION__, '2.5' );
     35    _deprecated_function( __FUNCTION__, '2.5', '' );
    3636    return;
    3737}
     
    5858 * {@internal Missing Short Description}}
    5959 *
    60  * @since 0.71
    61  * @deprecated 2.6.0
     60 * @since unknown
     61 * @deprecated unknown
    6262 * @deprecated Use wp_category_checklist()
    6363 * @see wp_category_checklist()
     
    6868 */
    6969function dropdown_categories( $default = 0, $parent = 0, $popular_ids = array() ) {
    70     _deprecated_function( __FUNCTION__, '2.6', 'wp_category_checklist()' );
     70    _deprecated_function( __FUNCTION__, '0.0', 'wp_category_checklist()' );
    7171    global $post_ID;
    7272    wp_category_checklist( $post_ID );
     
    7676 * {@internal Missing Short Description}}
    7777 *
    78  * @since 2.1.0
    79  * @deprecated 2.6.0
     78 * @since unknown
     79 * @deprecated unknown
    8080 * @deprecated Use wp_link_category_checklist()
    8181 * @see wp_link_category_checklist()
     
    8484 */
    8585function dropdown_link_categories( $default = 0 ) {
    86     _deprecated_function( __FUNCTION__, '2.6', 'wp_link_category_checklist()' );
     86    _deprecated_function( __FUNCTION__, '0.0', 'wp_link_category_checklist()' );
    8787    global $link_id;
    8888    wp_link_category_checklist( $link_id );
     
    9292 * {@internal Missing Short Description}}
    9393 *
    94  * @since 1.2.0
     94 * @since unknown
    9595 * @deprecated 3.0.0
    9696 * @deprecated Use wp_dropdown_categories()
     
    198198}
    199199
    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 }
     200?>
Note: See TracChangeset for help on using the changeset viewer.