Make WordPress Core


Ignore:
Timestamp:
06/24/2010 03:01:29 PM (16 years ago)
Author:
ryan
Message:

Use get_current_user() and get_current_user_id() instead of global . Props filofo. see #13934 for trunk

File:
1 edited

Legend:

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

    r15228 r15315  
    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";
Note: See TracChangeset for help on using the changeset viewer.