Changeset 36651
- Timestamp:
- 02/23/2016 10:25:32 PM (9 years ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/pluggable-deprecated.php
r36311 r36651 49 49 _deprecated_function( __FUNCTION__, '4.5', 'wp_get_current_user()' ); 50 50 51 return wp_get_current_user();51 return _wp_get_current_user(); 52 52 } 53 53 endif; -
trunk/src/wp-includes/pluggable.php
r36617 r36651 66 66 */ 67 67 function wp_get_current_user() { 68 global $current_user; 69 70 if ( ! empty( $current_user ) ) { 71 if ( $current_user instanceof WP_User ) { 72 return $current_user; 73 } 74 75 // Upgrade stdClass to WP_User 76 if ( is_object( $current_user ) && isset( $current_user->ID ) ) { 77 $cur_id = $current_user->ID; 78 $current_user = null; 79 wp_set_current_user( $cur_id ); 80 return $current_user; 81 } 82 83 // $current_user has a junk value. Force to WP_User with ID 0. 84 $current_user = null; 85 wp_set_current_user( 0 ); 86 return $current_user; 87 } 88 89 if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST ) { 90 wp_set_current_user( 0 ); 91 return $current_user; 92 } 93 94 /** 95 * Filter the current user. 96 * 97 * The default filters use this to determine the current user from the 98 * request's cookies, if available. 99 * 100 * Returning a value of false will effectively short-circuit setting 101 * the current user. 102 * 103 * @since 3.9.0 104 * 105 * @param int|bool $user_id User ID if one has been determined, false otherwise. 106 */ 107 $user_id = apply_filters( 'determine_current_user', false ); 108 if ( ! $user_id ) { 109 wp_set_current_user( 0 ); 110 return $current_user; 111 } 112 113 wp_set_current_user( $user_id ); 114 115 return $current_user; 68 return _wp_get_current_user(); 116 69 } 117 70 endif; -
trunk/src/wp-includes/user.php
r36617 r36651 2407 2407 return $users; 2408 2408 } 2409 2410 /** 2411 * Retrieve the current user object. 2412 * 2413 * Will set the current user, if the current user is not set. The current user 2414 * will be set to the logged-in person. If no user is logged-in, then it will 2415 * set the current user to 0, which is invalid and won't have any permissions. 2416 * 2417 * This function is used by the pluggable functions {@see wp_get_current_user()} 2418 * and {@see get_currentuserinfo()}, which is deprecated, for backward compatibility. 2419 * 2420 * @since 4.5.0 2421 * @access private 2422 * 2423 * @see https://core.trac.wordpress.org/ticket/19615 2424 * @global WP_User $current_user Checks if the current user is set. 2425 * 2426 * @return WP_User Current WP_User instance. 2427 */ 2428 function _wp_get_current_user() { 2429 global $current_user; 2430 2431 if ( ! empty( $current_user ) ) { 2432 if ( $current_user instanceof WP_User ) { 2433 return $current_user; 2434 } 2435 2436 // Upgrade stdClass to WP_User 2437 if ( is_object( $current_user ) && isset( $current_user->ID ) ) { 2438 $cur_id = $current_user->ID; 2439 $current_user = null; 2440 wp_set_current_user( $cur_id ); 2441 return $current_user; 2442 } 2443 2444 // $current_user has a junk value. Force to WP_User with ID 0. 2445 $current_user = null; 2446 wp_set_current_user( 0 ); 2447 return $current_user; 2448 } 2449 2450 if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST ) { 2451 wp_set_current_user( 0 ); 2452 return $current_user; 2453 } 2454 2455 /** 2456 * Filter the current user. 2457 * 2458 * The default filters use this to determine the current user from the 2459 * request's cookies, if available. 2460 * 2461 * Returning a value of false will effectively short-circuit setting 2462 * the current user. 2463 * 2464 * @since 3.9.0 2465 * 2466 * @param int|bool $user_id User ID if one has been determined, false otherwise. 2467 */ 2468 $user_id = apply_filters( 'determine_current_user', false ); 2469 if ( ! $user_id ) { 2470 wp_set_current_user( 0 ); 2471 return $current_user; 2472 } 2473 2474 wp_set_current_user( $user_id ); 2475 2476 return $current_user; 2477 }
Note: See TracChangeset
for help on using the changeset viewer.