Make WordPress Core

Changeset 15315


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

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

Location:
trunk
Files:
11 edited

Legend:

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

    r14673 r15315  
    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?>
  • trunk/wp-admin/includes/bookmark.php

    r13106 r15315  
    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 ) )
  • trunk/wp-admin/includes/class-wp-importer.php

    r15297 r15315  
    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' ) ) {
  • trunk/wp-admin/includes/meta-boxes.php

    r15190 r15315  
    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;
  • 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";
  • trunk/wp-admin/includes/post.php

    r15032 r15315  
    11711171 */
    11721172function wp_check_post_lock( $post_id ) {
    1173     global $current_user;
    1174 
    11751173    if ( !$post = get_post( $post_id ) )
    11761174        return false;
     
    11811179    $time_window = apply_filters( 'wp_check_post_lock_window', AUTOSAVE_INTERVAL * 2 );
    11821180
    1183     if ( $lock && $lock > time() - $time_window && $last != $current_user->ID )
     1181    if ( $lock && $lock > time() - $time_window && $last != get_current_user_id() )
    11841182        return $last;
    11851183    return false;
     
    11951193 */
    11961194function wp_set_post_lock( $post_id ) {
    1197     global $current_user;
    11981195    if ( !$post = get_post( $post_id ) )
    11991196        return false;
    1200     if ( !$current_user || !$current_user->ID )
     1197    if ( 0 == get_current_user_id() )
    12011198        return false;
    12021199
     
    12531250        $new_autosave = _wp_post_revision_fields( $_POST, true );
    12541251        $new_autosave['ID'] = $old_autosave->ID;
    1255         $current_user = wp_get_current_user();
    1256         $new_autosave['post_author'] = $current_user->ID;
     1252        $new_autosave['post_author'] = get_current_user_id();
    12571253        return wp_update_post( $new_autosave );
    12581254    }
  • trunk/wp-admin/includes/template.php

    r15280 r15315  
    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 ) :
     
    12691269 */
    12701270function _post_row($a_post, $pending_comments, $mode) {
    1271     global $post, $current_user, $current_screen;
     1271    global $post, $current_screen;
    12721272    static $rowclass;
    12731273
     
    12771277
    12781278    $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
    1279     $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
     1279    $post_owner = ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
    12801280    $edit_link = get_edit_post_link( $post->ID );
    12811281    $title = _draft_or_post_title();
     
    17951795    global $wp_roles;
    17961796
    1797     $current_user = wp_get_current_user();
    1798 
    17991797    if ( !( is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) )
    18001798        $user_object = new WP_User( (int) $user_object );
     
    18131811        // Set up the user editing link
    18141812        // TODO: make profile/user-edit determination a separate function
    1815         if ($current_user->ID == $user_object->ID) {
     1813        if ( get_current_user_id() == $user_object->ID) {
    18161814            $edit_link = 'profile.php';
    18171815        } else {
     
    18301828        }
    18311829
    1832         if ( !is_multisite() && $current_user->ID != $user_object->ID && current_user_can('delete_user', $user_object->ID) )
     1830        if ( !is_multisite() && get_current_user_id() != $user_object->ID && current_user_can('delete_user', $user_object->ID) )
    18331831            $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("users.php?action=delete&amp;user=$user_object->ID", 'bulk-users') . "'>" . __('Delete') . '</a>';
    1834         if ( is_multisite() && $current_user->ID != $user_object->ID && current_user_can('remove_user', $user_object->ID) )
     1832        if ( is_multisite() && get_current_user_id() != $user_object->ID && current_user_can('remove_user', $user_object->ID) )
    18351833            $actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url("users.php?action=remove&amp;user=$user_object->ID", 'bulk-users') . "'>" . __('Remove') . '</a>';
    18361834        $actions = apply_filters('user_row_actions', $actions, $user_object);
     
    22252223 */
    22262224function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', $table_row = true) {
    2227     global $current_user;
    2228 
    22292225    // allow plugin to replace the popup content
    22302226    $content = apply_filters( 'wp_comment_reply', '', array('position' => $position, 'checkbox' => $checkbox, 'mode' => $mode) );
     
    22782274    </p>
    22792275
    2280     <input type="hidden" name="user_ID" id="user_ID" value="<?php echo $current_user->ID; ?>" />
     2276    <input type="hidden" name="user_ID" id="user_ID" value="<?php echo get_current_user_id(); ?>" />
    22812277    <input type="hidden" name="action" id="action" value="" />
    22822278    <input type="hidden" name="comment_ID" id="comment_ID" value="" />
  • trunk/wp-admin/includes/user.php

    r14608 r15315  
    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
  • trunk/wp-includes/ms-blogs.php

    r15168 r15315  
    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 
     409 
     410    $current_user = wp_get_current_user();
    410411    if ( is_object( $current_user ) )
    411412        $current_user->for_blog( $blog_id );
     
    431432
    432433function restore_current_blog() {
    433     global $table_prefix, $wpdb, $blog_id, $switched, $switched_stack, $wp_roles, $current_user, $wp_object_cache;
     434    global $table_prefix, $wpdb, $blog_id, $switched, $switched_stack, $wp_roles, $wp_object_cache;
    434435
    435436    if ( !$switched )
     
    461462    }
    462463
     464    $current_user = wp_get_current_user();
    463465    if ( is_object( $current_user ) )
    464466        $current_user->for_blog( $blog_id );
  • trunk/wp-includes/ms-functions.php

    r15290 r15315  
    373373
    374374function is_blog_user( $blog_id = 0 ) {
    375     global $current_user, $wpdb;
    376 
     375    global $wpdb;
     376 
     377    $current_user = wp_get_current_user();
    377378    if ( !$blog_id )
    378379        $blog_id = $wpdb->blogid;
     
    13201321function is_user_spammy( $username = 0 ) {
    13211322    if ( $username == 0 ) {
    1322         global $current_user;
    1323         $user_id = $current_user->ID;
     1323        $user_id = get_current_user_id();
    13241324    } else {
    13251325        $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;
  • trunk/wp-signup.php

    r15235 r15315  
    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.