WordPress.org

Make WordPress Core

Changeset 3566


Ignore:
Timestamp:
02/22/2006 07:08:55 PM (12 years ago)
Author:
ryan
Message:

current user cleanup

Location:
trunk
Files:
15 edited

Legend:

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

    r3517 r3566  
    1818update_category_cache();
    1919
    20 get_currentuserinfo();
     20wp_get_current_user();
    2121
    2222$posts_per_page = get_settings('posts_per_page');
  • trunk/wp-admin/comment.php

    r3563 r3566  
    2727    require_once ('admin-header.php');
    2828
    29     get_currentuserinfo();
    30 
    3129    $comment = (int) $_GET['comment'];
    3230
  • trunk/wp-admin/edit-form-ajax-cat.php

    r3517 r3566  
    33require_once('admin-functions.php');
    44require_once('admin-db.php');
    5 
    6 get_currentuserinfo();
    75
    86if ( !current_user_can('manage_categories') )
  • trunk/wp-admin/list-manipulation.php

    r3529 r3566  
    44require_once('admin-db.php');
    55
    6 get_currentuserinfo();
    76if ( !is_user_logged_in() )
    87    die('-1');
  • trunk/wp-admin/options.php

    r3517 r3566  
    6969                // If home changed, write rewrite rules to new location.
    7070                $wp_rewrite->flush_rules();
    71                 // Get currently logged in user and password.
    72                 get_currentuserinfo();
    7371                // Clear cookies for old paths.
    7472                wp_clearcookie();
  • trunk/wp-admin/page-new.php

    r3563 r3566  
    1414if ( current_user_can('edit_pages') ) {
    1515    $action = 'post';
    16     get_currentuserinfo();
    17 
    1816    $post = get_default_post_to_edit();
    1917    $post->post_type = 'page';
  • trunk/wp-comments-post.php

    r3542 r3566  
    2525
    2626// If the user is logged in
    27 get_currentuserinfo();
    28 if ( $user_ID ) :
    29     $comment_author       = $wpdb->escape($user_identity);
    30     $comment_author_email = $wpdb->escape($user_email);
    31     $comment_author_url   = $wpdb->escape($user_url);
     27$user = wp_get_current_user();
     28if ( $user->ID ) :
     29    $comment_author       = $wpdb->escape($user->display_name);
     30    $comment_author_email = $wpdb->escape($user->user_email);
     31    $comment_author_url   = $wpdb->escape($user->user_url);
    3232else :
    3333    if ( get_option('comment_registration') )
     
    3737$comment_type = '';
    3838
    39 if ( get_settings('require_name_email') && !$user_ID ) {
     39if ( get_settings('require_name_email') && !$user->ID ) {
    4040    if ( 6 > strlen($comment_author_email) || '' == $comment_author )
    4141        die( __('Error: please fill the required fields (name, email).') );
     
    5151wp_new_comment( $commentdata );
    5252
    53 if ( !$user_ID ) :
     53if ( !$user->ID ) :
    5454    setcookie('comment_author_' . COOKIEHASH, stripslashes($comment_author), time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);
    5555    setcookie('comment_author_email_' . COOKIEHASH, stripslashes($comment_author_email), time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);
  • trunk/wp-includes/capabilities.php

    r3526 r3566  
    396396// Capability checking wrapper around the global $current_user object.
    397397function current_user_can($capability) {
    398     global $current_user;
     398    $current_user = wp_get_current_user();
    399399
    400400    $args = array_slice(func_get_args(), 1);
  • trunk/wp-includes/classes.php

    r3564 r3566  
    15881588
    15891589    function send_headers() {
    1590         global $current_user;
    15911590        @header('X-Pingback: '. get_bloginfo('pingback_url'));
    15921591        if ( is_user_logged_in() )
     
    16651664
    16661665    function init() {
    1667         get_currentuserinfo();
     1666        wp_get_current_user();
    16681667    }
    16691668
  • trunk/wp-includes/comment-functions.php

    r3537 r3566  
    1818        $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND ( comment_approved = '1' OR ( comment_author = '$author_db' AND comment_author_email = '$email_db' AND comment_approved = '0' ) ) ORDER BY comment_date");
    1919    }
    20 
    21     get_currentuserinfo();
    2220
    2321    define('COMMENTS_TEMPLATE', true);
  • trunk/wp-includes/functions.php

    r3559 r3566  
    304304
    305305function get_user_option( $option, $user = 0 ) {
    306     global $wpdb, $current_user;
     306    global $wpdb;
    307307
    308308    if ( empty($user) )
    309         $user = $current_user;
     309        $user = wp_get_current_user();
    310310    else
    311311        $user = get_userdata($user);
     
    11771177}
    11781178
     1179// Setup global user vars.  Used by set_current_user() for back compat.
     1180function setup_userdata($user_id = '') {
     1181    global $user_login, $userdata, $user_level, $user_ID, $user_email, $user_url, $user_pass_md5, $user_identity;
     1182
     1183    if ( '' == $user_id )
     1184        $user = wp_get_current_user();
     1185    else
     1186        $user = new WP_User($user_id);
     1187
     1188    if ( 0 == $user->ID )
     1189        return;
     1190
     1191    $userdata = $user->data;
     1192    $user_login = $user->user_login;
     1193    $user_level = $user->user_level;
     1194    $user_ID    = $user->ID;
     1195    $user_email = $user->user_email;
     1196    $user_url   = $user->user_url;
     1197    $user_pass_md5  = md5($user->user_pass);
     1198    $user_identity  = $user->display_name;
     1199}
     1200
    11791201function is_new_day() {
    11801202    global $day, $previousday;
  • trunk/wp-includes/kses.php

    r3430 r3566  
    529529
    530530function kses_init() {
    531     global $current_user;
    532 
    533531    remove_filter('pre_comment_author', 'wp_filter_kses');
    534532    remove_filter('pre_comment_content', 'wp_filter_kses');
    535533    remove_filter('content_save_pre', 'wp_filter_post_kses');
    536534    remove_filter('title_save_pre', 'wp_filter_kses');
    537 
    538     if (! defined('XMLRPC_REQUEST') )
    539         get_currentuserinfo();
    540535
    541536    if (current_user_can('unfiltered_html') == false)
  • trunk/wp-includes/pluggable-functions.php

    r3565 r3566  
    66if ( !function_exists('set_current_user') ) :
    77function set_current_user($id, $name = '') {
    8     global $user_login, $userdata, $user_level, $user_ID, $user_email, $user_url, $user_pass_md5, $user_identity, $current_user;
    9 
    10     $current_user   = '';
    11 
    12     $current_user   = new WP_User($id, $name);
    13 
    14     $userdata   = get_userdatabylogin($user_login);
    15 
    16     $user_login = $userdata->user_login;
    17     $user_level = $userdata->user_level;
    18     $user_ID    = $userdata->ID;
    19     $user_email = $userdata->user_email;
    20     $user_url   = $userdata->user_url;
    21     $user_pass_md5  = md5($userdata->user_pass);
    22     $user_identity  = $userdata->display_name;
     8    return wp_set_current_user($id, $name);
     9}
     10endif;
     11
     12if ( !function_exists('wp_set_current_user') ) :
     13function wp_set_current_user($id, $name = '') {
     14    global $current_user;
     15
     16    if ( isset($current_user) && ($id == $current_user->ID) )
     17        return $current_user;
     18
     19    $current_user = new WP_User($id, $name);
     20
     21    setup_userdata($current_user->ID);
    2322
    2423    do_action('set_current_user');
     
    2827endif;
    2928
     29if ( !function_exists('current_user') ) :
     30function wp_get_current_user() {
     31    global $current_user;
     32
     33    get_currentuserinfo();
     34
     35    return $current_user;
     36}
     37endif;
    3038
    3139if ( !function_exists('get_currentuserinfo') ) :
    3240function get_currentuserinfo() {
    33     global $user_login, $userdata, $user_level, $user_ID, $user_email, $user_url, $user_pass_md5, $user_identity, $current_user;
     41    global $current_user;
    3442
    3543    if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST )
    3644        return false;
     45
     46    if ( ! empty($current_user) )
     47        return;
    3748
    3849    if ( empty($_COOKIE[USER_COOKIE]) || empty($_COOKIE[PASS_COOKIE]) ||
    3950        !wp_login($_COOKIE[USER_COOKIE], $_COOKIE[PASS_COOKIE], true) ) {
    40         $current_user = new WP_User(0);
    41         return false;
    42     }
    43     $user_login  = $_COOKIE[USER_COOKIE];
    44     $userdata    = get_userdatabylogin($user_login);
    45     $user_level  = $userdata->user_level;
    46     $user_ID     = $userdata->ID;
    47     $user_email  = $userdata->user_email;
    48     $user_url    = $userdata->user_url;
    49     $user_pass_md5 = md5($userdata->user_pass);
    50     $user_identity = $userdata->display_name;
    51 
    52     if ( empty($current_user) )
    53         $current_user = new WP_User($user_ID);
     51        wp_set_current_user(0);
     52        return false;
     53    }
     54
     55    $user_login = $_COOKIE[USER_COOKIE];
     56    wp_set_current_user(0, $user_login);
    5457}
    5558endif;
     
    202205if ( !function_exists('is_user_logged_in') ) :
    203206function is_user_logged_in() {
    204     global $current_user;
    205 
    206     if ( $current_user->id == 0 )
    207         return false;
     207    $user = wp_get_current_user();
     208
     209    if ( $user->id == 0 )
     210        return false;
     211
    208212    return true;
    209213}
  • trunk/wp-includes/registration-functions.php

    r3517 r3566  
    102102
    103103function wp_update_user($userdata) {
    104     global $wpdb, $current_user;
     104    global $wpdb;
    105105
    106106    $ID = (int) $userdata['ID'];
     
    123123
    124124    // Update the cookies if the password changed.
     125    $current_user = wp_get_current_user();
    125126    if( $current_user->id == $ID ) {
    126127        if ( isset($plaintext_pass) ) {
  • trunk/wp-includes/template-functions-general.php

    r3549 r3566  
    2828
    2929function wp_loginout() {
    30     global $user_ID;
    31     get_currentuserinfo();
    32 
    33     if ('' == $user_ID)
     30    if ( ! is_user_logged_in() )
    3431        $link = '<a href="' . get_settings('siteurl') . '/wp-login.php">' . __('Login') . '</a>';
    3532    else
     
    4138
    4239function wp_register( $before = '<li>', $after = '</li>' ) {
    43     global $user_ID;
    44 
    45     get_currentuserinfo();
    46 
    47     if ( '' == $user_ID && get_settings('users_can_register') )
    48         $link = $before . '<a href="' . get_settings('siteurl') . '/wp-register.php">' . __('Register') . '</a>' . $after;
    49     elseif ( '' == $user_ID && !get_settings('users_can_register') )
    50         $link = '';
    51     else
     40
     41    if ( ! is_user_logged_in() ) {
     42        if ( get_settings('users_can_register') )
     43            $link = $before . '<a href="' . get_settings('siteurl') . '/wp-register.php">' . __('Register') . '</a>' . $after;
     44        else
     45            $link = '';
     46    } else {
    5247        $link = $before . '<a href="' . get_settings('siteurl') . '/wp-admin/">' . __('Site Admin') . '</a>' . $after;
     48    }
    5349
    5450    echo apply_filters('register', $link);
Note: See TracChangeset for help on using the changeset viewer.