Make WordPress Core

Changeset 15452


Ignore:
Timestamp:
07/21/2010 08:10:22 PM (14 years ago)
Author:
ryan
Message:

Use get_current_user() and get_current_user_id() instead of global current_user object. Props filofo. fixes #13934 for 3.0.1

Location:
branches/3.0
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/3.0/wp-admin/edit-attachment-rows.php

    r14673 r15452  
    4040
    4141$alt = ( 'alternate' == $alt ) ? '' : 'alternate';
    42 global $current_user;
    43 $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
     42
     43$post_owner = ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
    4444$att_title = _draft_or_post_title();
    4545?>
  • branches/3.0/wp-admin/includes/bookmark.php

    r13106 r15452  
    129129 */
    130130function wp_insert_link( $linkdata, $wp_error = false ) {
    131     global $wpdb, $current_user;
     131    global $wpdb;
    132132
    133133    $defaults = array( 'link_id' => 0, 'link_name' => '', 'link_url' => '', 'link_rating' => 0 );
     
    167167
    168168    if ( empty( $link_owner ) )
    169         $link_owner = $current_user->id;
     169        $link_owner = get_current_user_id();
    170170
    171171    if ( empty( $link_notes ) )
  • branches/3.0/wp-admin/includes/class-wp-importer.php

    r15298 r15452  
    217217     */
    218218    function is_user_over_quota() {
    219         global $current_user, $current_blog;
     219        global $current_blog;
    220220
    221221        if ( function_exists( 'upload_is_user_over_quota' ) ) {
  • branches/3.0/wp-admin/includes/meta-boxes.php

    r15190 r15452  
    502502 */
    503503function post_author_meta_box($post) {
    504     global $current_user, $user_ID;
    505     $authors = get_editable_user_ids( $current_user->id, true, $post->post_type ); // TODO: ROLE SYSTEM
     504    global $user_ID;
     505    $authors = get_editable_user_ids( get_current_user_id(), true, $post->post_type ); // TODO: ROLE SYSTEM
    506506    if ( $post->post_author && !in_array($post->post_author, $authors) )
    507507        $authors[] = $post->post_author;
  • branches/3.0/wp-admin/includes/ms.php

    r15382 r15452  
    179179
    180180function confirm_delete_users( $users ) {
    181     global $current_user;
     181    $current_user = wp_get_current_user();
    182182    if ( !is_array( $users ) )
    183183        return false;
    184184
    185     screen_icon();
    186     ?>
     185    screen_icon();
     186    ?>
    187187    <h2><?php esc_html_e( 'Users' ); ?></h2>
    188188    <p><?php _e( 'Transfer or delete posts and links before deleting users.' ); ?></p>
    189189    <form action="ms-edit.php?action=dodelete" method="post">
    190190    <input type="hidden" name="dodelete" />
    191     <?php
     191    <?php
    192192    wp_nonce_field( 'ms-users-delete' );
    193193    $site_admins = get_super_admins();
     
    312312
    313313function send_confirmation_on_profile_email() {
    314     global $errors, $wpdb, $current_user;
     314    global $errors, $wpdb;
     315    $current_user = wp_get_current_user();
    315316    if ( ! is_object($errors) )
    316317        $errors = new WP_Error();
     
    365366
    366367function new_user_email_admin_notice() {
    367     global $current_user;
    368     if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) && isset( $_GET['updated'] ) && $email = get_option( $current_user->ID . '_new_email' ) )
     368    if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) && isset( $_GET['updated'] ) && $email = get_option( get_current_user_id() . '_new_email' ) )
    369369        echo "<div class='update-nag'>" . sprintf( __( "Your email address has not been updated yet. Please check your inbox at %s for a confirmation email." ), $email['newemail'] ) . "</div>";
    370370}
     
    599599
    600600function redirect_user_to_blog() {
    601     global $current_user;
    602601    $c = 0;
    603602    if ( isset( $_GET['c'] ) )
     
    609608    $c ++;
    610609
    611     $blog = get_active_blog_for_user( $current_user->ID );
     610    $blog = get_active_blog_for_user( get_current_user_id() );
    612611    $dashboard_blog = get_dashboard_blog();
    613612    if ( is_object( $blog ) ) {
     
    620619       then update the primary_blog record to match the user's blog
    621620     */
    622     $blogs = get_blogs_of_user( $current_user->ID );
     621    $blogs = get_blogs_of_user( get_current_user_id() );
    623622
    624623    if ( !empty( $blogs ) ) {
    625624        foreach( $blogs as $blogid => $blog ) {
    626             if ( $blogid != $dashboard_blog->blog_id && get_user_meta( $current_user->ID , 'primary_blog', true ) == $dashboard_blog->blog_id ) {
    627                 update_user_meta( $current_user->ID, 'primary_blog', $blogid );
     625            if ( $blogid != $dashboard_blog->blog_id && get_user_meta( get_current_user_id() , 'primary_blog', true ) == $dashboard_blog->blog_id ) {
     626                update_user_meta( get_current_user_id(), 'primary_blog', $blogid );
    628627                continue;
    629628            }
    630629        }
    631         $blog = get_blog_details( get_user_meta( $current_user->ID, 'primary_blog', true ) );
     630        $blog = get_blog_details( get_user_meta( get_current_user_id(), 'primary_blog', true ) );
    632631            wp_redirect( get_admin_url( $blog->blog_id, '?c=' . $c ) );
    633632        exit;
     
    698697
    699698function admin_notice_feed() {
    700     global $current_user, $current_screen;
     699    global $current_screen;
    701700    if ( $current_screen->id != 'dashboard' )
    702701        return;
    703702
    704703    if ( !empty( $_GET['feed_dismiss'] ) ) {
    705         update_user_option( $current_user->id, 'admin_feed_dismiss', $_GET['feed_dismiss'], true );
     704        update_user_option( get_current_user_id(), 'admin_feed_dismiss', $_GET['feed_dismiss'], true );
    706705        return;
    707706    }
     
    729728
    730729function site_admin_notice() {
    731     global $current_user, $wp_db_version;
     730    global $wp_db_version;
    732731    if ( !is_super_admin() )
    733732        return false;
     
    761760
    762761function choose_primary_blog() {
    763     global $current_user;
    764762    ?>
    765763    <table class="form-table">
     
    769767        <td>
    770768        <?php
    771         $all_blogs = get_blogs_of_user( $current_user->ID );
    772         $primary_blog = get_user_meta( $current_user->ID, 'primary_blog', true );
     769        $all_blogs = get_blogs_of_user( get_current_user_id() );
     770        $primary_blog = get_user_meta( get_current_user_id(), 'primary_blog', true );
    773771        if ( count( $all_blogs ) > 1 ) {
    774772            $found = false;
     
    784782            if ( !$found ) {
    785783                $blog = array_shift( $all_blogs );
    786                 update_user_meta( $current_user->ID, 'primary_blog', $blog->userblog_id );
     784                update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id );
    787785            }
    788786        } elseif ( count( $all_blogs ) == 1 ) {
     
    790788            echo $blog->domain;
    791789            if ( $primary_blog != $blog->userblog_id ) // Set the primary blog again if it's out of sync with blog list.
    792                 update_user_meta( $current_user->ID, 'primary_blog', $blog->userblog_id );
     790                update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id );
    793791        } else {
    794792            echo "N/A";
  • branches/3.0/wp-admin/includes/post.php

    r15451 r15452  
    11731173 */
    11741174function wp_check_post_lock( $post_id ) {
    1175     global $current_user;
    1176 
    11771175    if ( !$post = get_post( $post_id ) )
    11781176        return false;
     
    11831181    $time_window = apply_filters( 'wp_check_post_lock_window', AUTOSAVE_INTERVAL * 2 );
    11841182
    1185     if ( $lock && $lock > time() - $time_window && $last != $current_user->ID )
     1183    if ( $lock && $lock > time() - $time_window && $last != get_current_user_id() )
    11861184        return $last;
    11871185    return false;
     
    11971195 */
    11981196function wp_set_post_lock( $post_id ) {
    1199     global $current_user;
    12001197    if ( !$post = get_post( $post_id ) )
    12011198        return false;
    1202     if ( !$current_user || !$current_user->ID )
     1199    if ( 0 == get_current_user_id() )
    12031200        return false;
    12041201
     
    12551252        $new_autosave = _wp_post_revision_fields( $_POST, true );
    12561253        $new_autosave['ID'] = $old_autosave->ID;
    1257         $current_user = wp_get_current_user();
    1258         $new_autosave['post_author'] = $current_user->ID;
     1254        $new_autosave['post_author'] = get_current_user_id();
    12591255        return wp_update_post( $new_autosave );
    12601256    }
  • branches/3.0/wp-admin/includes/template.php

    r15337 r15452  
    848848 */
    849849function inline_edit_row( $screen ) {
    850     global $current_user, $mode;
     850    global $mode;
    851851
    852852    if ( is_string($screen) ) {
     
    929929
    930930    if ( post_type_supports( $screen->post_type, 'author' ) ) :
    931         $authors = get_editable_user_ids( $current_user->id, true, $screen->post_type ); // TODO: ROLE SYSTEM
     931        $authors = get_editable_user_ids( get_current_user_id(), true, $screen->post_type ); // TODO: ROLE SYSTEM
    932932        $authors_dropdown = '';
    933933        if ( $authors && count( $authors ) > 1 ) :
     
    12701270 */
    12711271function _post_row($a_post, $pending_comments, $mode) {
    1272     global $post, $current_user, $current_screen;
     1272    global $post, $current_screen;
    12731273    static $rowclass;
    12741274
     
    12781278
    12791279    $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
    1280     $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
     1280    $post_owner = ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
    12811281    $edit_link = get_edit_post_link( $post->ID );
    12821282    $title = _draft_or_post_title();
     
    17961796    global $wp_roles;
    17971797
    1798     $current_user = wp_get_current_user();
    1799 
    18001798    if ( !( is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) )
    18011799        $user_object = new WP_User( (int) $user_object );
     
    18141812        // Set up the user editing link
    18151813        // TODO: make profile/user-edit determination a separate function
    1816         if ($current_user->ID == $user_object->ID) {
     1814        if ( get_current_user_id() == $user_object->ID) {
    18171815            $edit_link = 'profile.php';
    18181816        } else {
     
    18311829        }
    18321830
    1833         if ( !is_multisite() && $current_user->ID != $user_object->ID && current_user_can('delete_user', $user_object->ID) )
     1831        if ( !is_multisite() && get_current_user_id() != $user_object->ID && current_user_can('delete_user', $user_object->ID) )
    18341832            $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("users.php?action=delete&amp;user=$user_object->ID", 'bulk-users') . "'>" . __('Delete') . "</a>";
    1835         if ( is_multisite() && $current_user->ID != $user_object->ID && current_user_can('remove_user', $user_object->ID) )
     1833        if ( is_multisite() && get_current_user_id() != $user_object->ID && current_user_can('remove_user', $user_object->ID) )
    18361834            $actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url("users.php?action=remove&amp;user=$user_object->ID", 'bulk-users') . "'>" . __('Remove') . "</a>";
    18371835        $actions = apply_filters('user_row_actions', $actions, $user_object);
     
    22262224 */
    22272225function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', $table_row = true) {
    2228     global $current_user;
    2229 
    22302226    // allow plugin to replace the popup content
    22312227    $content = apply_filters( 'wp_comment_reply', '', array('position' => $position, 'checkbox' => $checkbox, 'mode' => $mode) );
     
    22792275    </p>
    22802276
    2281     <input type="hidden" name="user_ID" id="user_ID" value="<?php echo $current_user->ID; ?>" />
     2277    <input type="hidden" name="user_ID" id="user_ID" value="<?php echo get_current_user_id(); ?>" />
    22822278    <input type="hidden" name="action" id="action" value="" />
    22832279    <input type="hidden" name="comment_ID" id="comment_ID" value="" />
  • branches/3.0/wp-admin/includes/user.php

    r14608 r15452  
    2222function add_user() {
    2323    if ( func_num_args() ) { // The hackiest hack that ever did hack
    24         global $current_user, $wp_roles;
     24        global $wp_roles;
    2525        $user_id = (int) func_get_arg( 0 );
    2626
     
    2828            $new_role = sanitize_text_field( $_POST['role'] );
    2929            // Don't let anyone with 'edit_users' (admins) edit their own role to something without it.
    30             if ( $user_id != $current_user->id || $wp_roles->role_objects[$new_role]->has_cap( 'edit_users' ) ) {
     30            if ( $user_id != get_current_user_id() || $wp_roles->role_objects[$new_role]->has_cap( 'edit_users' ) ) {
    3131                // If the new role isn't editable by the logged-in user die with error
    3232                $editable_roles = get_editable_roles();
     
    5555 */
    5656function edit_user( $user_id = 0 ) {
    57     global $current_user, $wp_roles, $wpdb;
     57    global $wp_roles, $wpdb;
    5858    if ( $user_id != 0 ) {
    5959        $update = true;
     
    8080        // Don't let anyone with 'edit_users' (admins) edit their own role to something without it.
    8181        // Multisite super admins can freely edit their blog roles -- they possess all caps.
    82         if ( ( is_multisite() && current_user_can( 'manage_sites' ) ) || $user_id != $current_user->id || ($potential_role && $potential_role->has_cap( 'edit_users' ) ) )
     82        if ( ( is_multisite() && current_user_can( 'manage_sites' ) ) || $user_id != get_current_user_id() || ($potential_role && $potential_role->has_cap( 'edit_users' ) ) )
    8383            $user->role = $new_role;
    8484
  • branches/3.0/wp-includes/ms-blogs.php

    r15168 r15452  
    372372
    373373function switch_to_blog( $new_blog, $validate = false ) {
    374     global $wpdb, $table_prefix, $blog_id, $switched, $switched_stack, $wp_roles, $current_user, $wp_object_cache;
     374    global $wpdb, $table_prefix, $blog_id, $switched, $switched_stack, $wp_roles, $wp_object_cache;
    375375
    376376    if ( empty($new_blog) )
     
    407407        $wpdb->suppress_errors( false );
    408408    }
    409 
    410     if ( is_object( $current_user ) )
    411         $current_user->for_blog( $blog_id );
     409 
     410    if ( did_action('init') ) {
     411        $current_user = wp_get_current_user(); 
     412        if ( is_object( $current_user ) )
     413            $current_user->for_blog( $blog_id );
     414    }
    412415
    413416    if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) )
     
    431434
    432435function restore_current_blog() {
    433     global $table_prefix, $wpdb, $blog_id, $switched, $switched_stack, $wp_roles, $current_user, $wp_object_cache;
     436    global $table_prefix, $wpdb, $blog_id, $switched, $switched_stack, $wp_roles, $wp_object_cache;
    434437
    435438    if ( !$switched )
     
    461464    }
    462465
    463     if ( is_object( $current_user ) )
    464         $current_user->for_blog( $blog_id );
     466    if ( did_action('init') ) {
     467        $current_user = wp_get_current_user();
     468        if ( is_object( $current_user ) )
     469            $current_user->for_blog( $blog_id );
     470    }
    465471
    466472    if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) )
  • branches/3.0/wp-includes/ms-functions.php

    r15403 r15452  
    376376
    377377function is_blog_user( $blog_id = 0 ) {
    378     global $current_user, $wpdb;
    379 
     378    global $wpdb;
     379 
     380    $current_user = wp_get_current_user();
    380381    if ( !$blog_id )
    381382        $blog_id = $wpdb->blogid;
     
    13231324function is_user_spammy( $username = 0 ) {
    13241325    if ( $username == 0 ) {
    1325         global $current_user;
    1326         $user_id = $current_user->ID;
     1326        $user_id = get_current_user_id();
    13271327    } else {
    13281328        $user_id = get_user_id_from_string( $username );
     
    13611361
    13621362function is_user_option_local( $key, $user_id = 0, $blog_id = 0 ) {
    1363     global $current_user, $wpdb;
    1364 
     1363    global $wpdb;
     1364
     1365    $current_user = wp_get_current_user();
    13651366    if ( $user_id == 0 )
    13661367        $user_id = $current_user->ID;
  • branches/3.0/wp-signup.php

    r15235 r15452  
    154154
    155155function signup_another_blog($blogname = '', $blog_title = '', $errors = '') {
    156     global $current_user, $current_site;
     156    global $current_site;
     157    $current_user = wp_get_current_user();
    157158
    158159    if ( ! is_wp_error($errors) ) {
     
    198199
    199200function validate_another_blog_signup() {
    200     global $wpdb, $current_user, $blogname, $blog_title, $errors, $domain, $path;
     201    global $wpdb, $blogname, $blog_title, $errors, $domain, $path;
    201202    $current_user = wp_get_current_user();
    202203    if ( !is_user_logged_in() )
Note: See TracChangeset for help on using the changeset viewer.