Ticket #13934: current-user-assumptions.13934.diff
File current-user-assumptions.13934.diff, 18.4 KB (added by , 15 years ago) |
---|
-
wp-signup.php
153 153 } 154 154 155 155 function signup_another_blog($blogname = '', $blog_title = '', $errors = '') { 156 global $current_user, $current_site; 156 global $current_site; 157 $current_user = wp_get_current_user(); 157 158 158 159 if ( ! is_wp_error($errors) ) { 159 160 $errors = new WP_Error(); … … 197 198 } 198 199 199 200 function validate_another_blog_signup() { 200 global $wpdb, $ current_user, $blogname, $blog_title, $errors, $domain, $path;201 global $wpdb, $blogname, $blog_title, $errors, $domain, $path; 201 202 $current_user = wp_get_current_user(); 202 203 if ( !is_user_logged_in() ) 203 204 die(); -
wp-includes/ms-blogs.php
371 371 } 372 372 373 373 function 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; 375 375 376 376 if ( empty($new_blog) ) 377 377 $new_blog = $blog_id; … … 406 406 $wp_roles->__construct(); 407 407 $wpdb->suppress_errors( false ); 408 408 } 409 409 410 $current_user = wp_get_current_user(); 410 411 if ( is_object( $current_user ) ) 411 412 $current_user->for_blog( $blog_id ); 412 413 … … 430 431 } 431 432 432 433 function 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; 434 435 435 436 if ( !$switched ) 436 437 return false; … … 460 461 $wpdb->suppress_errors( false ); 461 462 } 462 463 464 $current_user = wp_get_current_user(); 463 465 if ( is_object( $current_user ) ) 464 466 $current_user->for_blog( $blog_id ); 465 467 -
wp-includes/ms-functions.php
372 372 } 373 373 374 374 function is_blog_user( $blog_id = 0 ) { 375 global $current_user, $wpdb; 376 375 global $wpdb; 376 377 $current_user = wp_get_current_user(); 377 378 if ( !$blog_id ) 378 379 $blog_id = $wpdb->blogid; 379 380 … … 1319 1320 1320 1321 function is_user_spammy( $username = 0 ) { 1321 1322 if ( $username == 0 ) { 1322 global $current_user; 1323 $user_id = $current_user->ID; 1323 $user_id = get_current_user_id(); 1324 1324 } else { 1325 1325 $user_id = get_user_id_from_string( $username ); 1326 1326 } … … 1360 1360 } 1361 1361 1362 1362 function is_user_option_local( $key, $user_id = 0, $blog_id = 0 ) { 1363 global $ current_user, $wpdb;1363 global $wpdb; 1364 1364 1365 $current_user = wp_get_current_user(); 1365 1366 if ( $user_id == 0 ) 1366 1367 $user_id = $current_user->ID; 1367 1368 if ( $blog_id == 0 ) -
wp-admin/includes/bookmark.php
128 128 * @return unknown 129 129 */ 130 130 function wp_insert_link( $linkdata, $wp_error = false ) { 131 global $wpdb , $current_user;131 global $wpdb; 132 132 133 133 $defaults = array( 'link_id' => 0, 'link_name' => '', 'link_url' => '', 'link_rating' => 0 ); 134 134 … … 166 166 $link_visible = 'Y'; 167 167 168 168 if ( empty( $link_owner ) ) 169 $link_owner = $current_user->id;169 $link_owner = get_current_user_id(); 170 170 171 171 if ( empty( $link_notes ) ) 172 172 $link_notes = ''; -
wp-admin/includes/post.php
1170 1170 * @return bool|int False: not locked or locked by current user. Int: user ID of user with lock. 1171 1171 */ 1172 1172 function wp_check_post_lock( $post_id ) { 1173 global $current_user;1174 1175 1173 if ( !$post = get_post( $post_id ) ) 1176 1174 return false; 1177 1175 … … 1180 1178 1181 1179 $time_window = apply_filters( 'wp_check_post_lock_window', AUTOSAVE_INTERVAL * 2 ); 1182 1180 1183 if ( $lock && $lock > time() - $time_window && $last != $current_user->ID)1181 if ( $lock && $lock > time() - $time_window && $last != get_current_user_id() ) 1184 1182 return $last; 1185 1183 return false; 1186 1184 } … … 1194 1192 * @return bool Returns false if the post doesn't exist of there is no current user 1195 1193 */ 1196 1194 function wp_set_post_lock( $post_id ) { 1197 global $current_user;1198 1195 if ( !$post = get_post( $post_id ) ) 1199 1196 return false; 1200 if ( !$current_user || !$current_user->ID)1197 if ( 0 == get_current_user_id() ) 1201 1198 return false; 1202 1199 1203 1200 $now = time(); … … 1252 1249 if ( $old_autosave = wp_get_post_autosave( $post_id ) ) { 1253 1250 $new_autosave = _wp_post_revision_fields( $_POST, true ); 1254 1251 $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(); 1257 1253 return wp_update_post( $new_autosave ); 1258 1254 } 1259 1255 … … 1611 1607 /* ]]> */ 1612 1608 </script> 1613 1609 <?php 1614 } 1615 No newline at end of file 1610 } -
wp-admin/includes/meta-boxes.php
501 501 * @param object $post 502 502 */ 503 503 function 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 SYSTEM504 global $user_ID; 505 $authors = get_editable_user_ids( get_current_user_id(), true, $post->post_type ); // TODO: ROLE SYSTEM 506 506 if ( $post->post_author && !in_array($post->post_author, $authors) ) 507 507 $authors[] = $post->post_author; 508 508 ?> -
wp-admin/includes/template.php
847 847 * @param string $screen 848 848 */ 849 849 function inline_edit_row( $screen ) { 850 global $ current_user, $mode;850 global $mode; 851 851 852 852 if ( is_string($screen) ) { 853 853 $screen = array('id' => 'edit-' . $screen, 'base' => 'edit', 'post_type' => $screen ); … … 928 928 <?php endif; // $bulk 929 929 930 930 if ( post_type_supports( $screen->post_type, 'author' ) ) : 931 $authors = get_editable_user_ids( $current_user->id, true, $screen->post_type ); // TODO: ROLE SYSTEM931 $authors = get_editable_user_ids( get_current_user_id(), true, $screen->post_type ); // TODO: ROLE SYSTEM 932 932 $authors_dropdown = ''; 933 933 if ( $authors && count( $authors ) > 1 ) : 934 934 $users_opt = array('include' => $authors, 'name' => 'post_author', 'class'=> 'authors', 'multi' => 1, 'echo' => 0); … … 1269 1269 * @param unknown_type $mode 1270 1270 */ 1271 1271 function _post_row($a_post, $pending_comments, $mode) { 1272 global $post, $current_ user, $current_screen;1272 global $post, $current_screen; 1273 1273 static $rowclass; 1274 1274 1275 1275 $global_post = $post; … … 1277 1277 setup_postdata($post); 1278 1278 1279 1279 $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' ); 1281 1281 $edit_link = get_edit_post_link( $post->ID ); 1282 1282 $title = _draft_or_post_title(); 1283 1283 $post_type_object = get_post_type_object($post->post_type); … … 1795 1795 function user_row( $user_object, $style = '', $role = '', $numposts = 0 ) { 1796 1796 global $wp_roles; 1797 1797 1798 $current_user = wp_get_current_user();1799 1800 1798 if ( !( is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) ) 1801 1799 $user_object = new WP_User( (int) $user_object ); 1802 1800 $user_object = sanitize_user_object($user_object, 'display'); … … 1813 1811 if ( current_user_can( 'list_users' ) ) { 1814 1812 // Set up the user editing link 1815 1813 // 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) { 1817 1815 $edit_link = 'profile.php'; 1818 1816 } else { 1819 1817 $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( esc_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=$user_object->ID" ) ); … … 1830 1828 $edit = "<strong>$user_object->user_login</strong><br />"; 1831 1829 } 1832 1830 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) ) 1834 1832 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("users.php?action=delete&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) ) 1836 1834 $actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url("users.php?action=remove&user=$user_object->ID", 'bulk-users') . "'>" . __('Remove') . "</a>"; 1837 1835 $actions = apply_filters('user_row_actions', $actions, $user_object); 1838 1836 $action_count = count($actions); … … 2225 2223 * @param unknown_type $mode 2226 2224 */ 2227 2225 function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', $table_row = true) { 2228 global $current_user;2229 2230 2226 // allow plugin to replace the popup content 2231 2227 $content = apply_filters( 'wp_comment_reply', '', array('position' => $position, 'checkbox' => $checkbox, 'mode' => $mode) ); 2232 2228 … … 2278 2274 <br class="clear" /> 2279 2275 </p> 2280 2276 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(); ?>" /> 2282 2278 <input type="hidden" name="action" id="action" value="" /> 2283 2279 <input type="hidden" name="comment_ID" id="comment_ID" value="" /> 2284 2280 <input type="hidden" name="comment_post_ID" id="comment_post_ID" value="" /> -
wp-admin/includes/user.php
21 21 */ 22 22 function add_user() { 23 23 if ( func_num_args() ) { // The hackiest hack that ever did hack 24 global $ current_user, $wp_roles;24 global $wp_roles; 25 25 $user_id = (int) func_get_arg( 0 ); 26 26 27 27 if ( isset( $_POST['role'] ) ) { 28 28 $new_role = sanitize_text_field( $_POST['role'] ); 29 29 // 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' ) ) { 31 31 // If the new role isn't editable by the logged-in user die with error 32 32 $editable_roles = get_editable_roles(); 33 33 if ( empty( $editable_roles[$new_role] ) ) … … 54 54 * @return int user id of the updated user 55 55 */ 56 56 function edit_user( $user_id = 0 ) { 57 global $ current_user, $wp_roles, $wpdb;57 global $wp_roles, $wpdb; 58 58 if ( $user_id != 0 ) { 59 59 $update = true; 60 60 $user->ID = (int) $user_id; … … 79 79 $potential_role = isset($wp_roles->role_objects[$new_role]) ? $wp_roles->role_objects[$new_role] : false; 80 80 // Don't let anyone with 'edit_users' (admins) edit their own role to something without it. 81 81 // 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' ) ) ) 83 83 $user->role = $new_role; 84 84 85 85 // If the new role isn't editable by the logged-in user die with error -
wp-admin/includes/ms.php
178 178 } 179 179 180 180 function confirm_delete_users( $users ) { 181 global $current_user;181 $current_user = wp_get_current_user(); 182 182 if ( !is_array( $users ) ) 183 183 return false; 184 184 185 186 185 screen_icon(); 186 ?> 187 187 <h2><?php esc_html_e( 'Users' ); ?></h2> 188 188 <p><?php _e( 'Transfer or delete posts and links before deleting users.' ); ?></p> 189 189 <form action="ms-edit.php?action=dodelete" method="post"> 190 190 <input type="hidden" name="dodelete" /> 191 191 <?php 192 192 wp_nonce_field( 'ms-users-delete' ); 193 193 $site_admins = get_super_admins(); 194 194 $admin_out = "<option value='$current_user->ID'>$current_user->user_login</option>"; … … 311 311 add_action( 'add_option_new_admin_email', 'update_option_new_admin_email', 10, 2 ); 312 312 313 313 function send_confirmation_on_profile_email() { 314 global $errors, $wpdb, $current_user; 314 global $errors, $wpdb; 315 $current_user = wp_get_current_user(); 315 316 if ( ! is_object($errors) ) 316 317 $errors = new WP_Error(); 317 318 … … 364 365 add_action( 'personal_options_update', 'send_confirmation_on_profile_email' ); 365 366 366 367 function 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' ) ) 369 369 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>"; 370 370 } 371 371 add_action( 'admin_notices', 'new_user_email_admin_notice' ); … … 598 598 add_filter( 'get_term', 'sync_category_tag_slugs', 10, 2 ); 599 599 600 600 function redirect_user_to_blog() { 601 global $current_user;602 601 $c = 0; 603 602 if ( isset( $_GET['c'] ) ) 604 603 $c = (int) $_GET['c']; … … 608 607 } 609 608 $c ++; 610 609 611 $blog = get_active_blog_for_user( $current_user->ID);610 $blog = get_active_blog_for_user( get_current_user_id() ); 612 611 $dashboard_blog = get_dashboard_blog(); 613 612 if ( is_object( $blog ) ) { 614 613 wp_redirect( get_admin_url( $blog->blog_id, '?c=' . $c ) ); // redirect and count to 5, "just in case" … … 619 618 If the user is a member of only 1 blog and the user's primary_blog isn't set to that blog, 620 619 then update the primary_blog record to match the user's blog 621 620 */ 622 $blogs = get_blogs_of_user( $current_user->ID);621 $blogs = get_blogs_of_user( get_current_user_id() ); 623 622 624 623 if ( !empty( $blogs ) ) { 625 624 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 ); 628 627 continue; 629 628 } 630 629 } 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 ) ); 632 631 wp_redirect( get_admin_url( $blog->blog_id, '?c=' . $c ) ); 633 632 exit; 634 633 } … … 697 696 add_action( 'admin_notices', 'secret_salt_warning' ); 698 697 699 698 function admin_notice_feed() { 700 global $current_ user, $current_screen;699 global $current_screen; 701 700 if ( $current_screen->id != 'dashboard' ) 702 701 return; 703 702 704 703 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 ); 706 705 return; 707 706 } 708 707 … … 728 727 add_action( 'admin_notices', 'admin_notice_feed' ); 729 728 730 729 function site_admin_notice() { 731 global $ current_user, $wp_db_version;730 global $wp_db_version; 732 731 if ( !is_super_admin() ) 733 732 return false; 734 733 if ( get_site_option( 'wpmu_upgrade_site' ) != $wp_db_version ) … … 760 759 add_filter( 'wp_insert_post_data', 'avoid_blog_page_permalink_collision', 10, 2 ); 761 760 762 761 function choose_primary_blog() { 763 global $current_user;764 762 ?> 765 763 <table class="form-table"> 766 764 <tr> … … 768 766 <th scope="row"><?php _e( 'Primary Site' ); ?></th> 769 767 <td> 770 768 <?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 ); 773 771 if ( count( $all_blogs ) > 1 ) { 774 772 $found = false; 775 773 ?> … … 783 781 <?php 784 782 if ( !$found ) { 785 783 $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 ); 787 785 } 788 786 } elseif ( count( $all_blogs ) == 1 ) { 789 787 $blog = array_shift( $all_blogs ); 790 788 echo $blog->domain; 791 789 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 ); 793 791 } else { 794 792 echo "N/A"; 795 793 } -
wp-admin/includes/class-wp-importer.php
215 215 * @return bool 216 216 */ 217 217 function is_user_over_quota() { 218 global $current_ user, $current_blog;218 global $current_blog; 219 219 220 220 if ( function_exists( 'upload_is_user_over_quota' ) ) { 221 221 if ( upload_is_user_over_quota( 1 ) ) { -
wp-admin/edit-attachment-rows.php
39 39 continue; 40 40 41 41 $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' ); 44 44 $att_title = _draft_or_post_title(); 45 45 ?> 46 46 <tr id='post-<?php echo $id; ?>' class='<?php echo trim( $alt . ' author-' . $post_owner . ' status-' . $post->post_status ); ?>' valign="top">