Ticket #37699: 37699-get_current_blog_id.diff
File 37699-get_current_blog_id.diff, 9.6 KB (added by , 8 years ago) |
---|
-
src/wp-admin/includes/class-wp-themes-list-table.php
91 91 return; 92 92 } 93 93 94 $blog_id = get_current_blog_id(); 94 95 if ( is_multisite() ) { 95 96 if ( current_user_can( 'install_themes' ) && current_user_can( 'manage_network_themes' ) ) { 96 printf( __( 'You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> or <a href="%2$s">install</a> more themes.' ), network_admin_url( 'site-themes.php?id=' . $ GLOBALS['blog_id']), network_admin_url( 'theme-install.php' ) );97 printf( __( 'You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> or <a href="%2$s">install</a> more themes.' ), network_admin_url( 'site-themes.php?id=' . $blog_id ), network_admin_url( 'theme-install.php' ) ); 97 98 98 99 return; 99 100 } elseif ( current_user_can( 'manage_network_themes' ) ) { 100 printf( __( 'You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> more themes.' ), network_admin_url( 'site-themes.php?id=' . $ GLOBALS['blog_id']) );101 printf( __( 'You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> more themes.' ), network_admin_url( 'site-themes.php?id=' . $blog_id ) ); 101 102 102 103 return; 103 104 } -
src/wp-includes/cache.php
729 729 * Sets up object properties; PHP 5 style constructor. 730 730 * 731 731 * @since 2.0.8 732 *733 * @global int $blog_id Global blog ID.734 732 */ 735 733 public function __construct() { 736 global $blog_id;737 738 734 $this->multisite = is_multisite(); 739 $this->blog_prefix = $this->multisite ? $blog_id. ':' : '';735 $this->blog_prefix = $this->multisite ? get_current_blog_id() . ':' : ''; 740 736 741 737 742 738 /** -
src/wp-includes/class-wp-user-query.php
104 104 */ 105 105 public static function fill_query_vars( $args ) { 106 106 $defaults = array( 107 'blog_id' => $GLOBALS['blog_id'],107 'blog_id' => get_current_blog_id(), 108 108 'role' => '', 109 109 'role__in' => array(), 110 110 'role__not_in' => array(), -
src/wp-includes/deprecated.php
2357 2357 * @see get_users() 2358 2358 * 2359 2359 * @global wpdb $wpdb WordPress database abstraction object. 2360 * @global int $blog_id The site ID of the site for those that use more than one site.2361 2360 * 2362 2361 * @param int $id Site ID. 2363 2362 * @return array List of users that are part of that site ID … … 2365 2364 function get_users_of_blog( $id = '' ) { 2366 2365 _deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' ); 2367 2366 2368 global $wpdb, $blog_id; 2369 if ( empty($id) ) 2370 $id = (int) $blog_id; 2367 global $wpdb; 2368 if ( empty( $id ) ) { 2369 $id = get_current_blog_id(); 2370 } 2371 2371 $blog_prefix = $wpdb->get_blog_prefix($id); 2372 2372 $users = $wpdb->get_results( "SELECT user_id, user_id AS ID, user_login, display_name, user_email, meta_value FROM $wpdb->users, $wpdb->usermeta WHERE {$wpdb->users}.ID = {$wpdb->usermeta}.user_id AND meta_key = '{$blog_prefix}capabilities' ORDER BY {$wpdb->usermeta}.user_id" ); 2373 2373 return $users; -
src/wp-includes/load.php
470 470 * 471 471 * @since 3.0.0 472 472 * @access private 473 *474 * @global int $blog_id Blog ID.475 473 */ 476 474 function wp_start_object_cache() { 477 global $blog_id;478 479 475 $first_init = false; 480 476 if ( ! function_exists( 'wp_cache_init' ) ) { 481 477 if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { 482 478 require_once ( WP_CONTENT_DIR . '/object-cache.php' ); 483 if ( function_exists( 'wp_cache_init' ) ) 479 if ( function_exists( 'wp_cache_init' ) ) { 484 480 wp_using_ext_object_cache( true ); 481 } 485 482 } 486 483 487 484 $first_init = true; … … 495 492 wp_using_ext_object_cache( true ); 496 493 } 497 494 498 if ( ! wp_using_ext_object_cache() ) 495 if ( ! wp_using_ext_object_cache() ) { 499 496 require_once ( ABSPATH . WPINC . '/cache.php' ); 497 } 500 498 501 499 /* 502 500 * If cache supports reset, reset instead of init if already … … 503 501 * initialized. Reset signals to the cache that global IDs 504 502 * have changed and it may need to update keys and cleanup caches. 505 503 */ 506 if ( ! $first_init && function_exists( 'wp_cache_switch_to_blog' ) ) 507 wp_cache_switch_to_blog( $blog_id);508 elseif ( function_exists( 'wp_cache_init' ) )504 if ( ! $first_init && function_exists( 'wp_cache_switch_to_blog' ) ) { 505 wp_cache_switch_to_blog( get_current_blog_id() ); 506 } elseif ( function_exists( 'wp_cache_init' ) ) { 509 507 wp_cache_init(); 508 } 510 509 511 510 if ( function_exists( 'wp_cache_add_global_groups' ) ) { 512 511 wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'site-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites' ) ); -
src/wp-includes/ms-blogs.php
766 766 function switch_to_blog( $new_blog, $deprecated = null ) { 767 767 global $wpdb; 768 768 769 if ( empty( $new_blog ) ) 770 $new_blog = $GLOBALS['blog_id']; 769 $blog_id = get_current_blog_id(); 770 if ( empty( $new_blog ) ) { 771 $new_blog = $blog_id; 772 } 771 773 772 $GLOBALS['_wp_switched_stack'][] = $ GLOBALS['blog_id'];774 $GLOBALS['_wp_switched_stack'][] = $blog_id; 773 775 774 776 /* 775 777 * If we're switching to the same blog id that we're on, … … 776 778 * set the right vars, do the associated actions, but skip 777 779 * the extra unnecessary work 778 780 */ 779 if ( $new_blog == $ GLOBALS['blog_id']) {781 if ( $new_blog == $blog_id ) { 780 782 /** 781 783 * Fires when the blog is switched. 782 784 * … … 792 794 793 795 $wpdb->set_blog_id( $new_blog ); 794 796 $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); 795 $prev_blog_id = $ GLOBALS['blog_id'];797 $prev_blog_id = $blog_id; 796 798 $GLOBALS['blog_id'] = $new_blog; 797 799 798 800 if ( function_exists( 'wp_cache_switch_to_blog' ) ) { … … 800 802 } else { 801 803 global $wp_object_cache; 802 804 803 if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) ) 805 if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) ) { 804 806 $global_groups = $wp_object_cache->global_groups; 805 else807 } else { 806 808 $global_groups = false; 807 809 } 808 810 wp_cache_init(); 809 811 810 812 if ( function_exists( 'wp_cache_add_global_groups' ) ) { … … 848 850 function restore_current_blog() { 849 851 global $wpdb; 850 852 851 if ( empty( $GLOBALS['_wp_switched_stack'] ) ) 853 if ( empty( $GLOBALS['_wp_switched_stack'] ) ) { 852 854 return false; 855 } 853 856 854 857 $blog = array_pop( $GLOBALS['_wp_switched_stack'] ); 858 $blog_id = get_current_blog_id(); 855 859 856 if ( $ GLOBALS['blog_id']== $blog ) {860 if ( $blog_id == $blog ) { 857 861 /** This filter is documented in wp-includes/ms-blogs.php */ 858 862 do_action( 'switch_blog', $blog, $blog ); 859 863 // If we still have items in the switched stack, consider ourselves still 'switched' … … 862 866 } 863 867 864 868 $wpdb->set_blog_id( $blog ); 865 $prev_blog_id = $ GLOBALS['blog_id'];869 $prev_blog_id = $blog_id; 866 870 $GLOBALS['blog_id'] = $blog; 867 871 $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); 868 872 … … 871 875 } else { 872 876 global $wp_object_cache; 873 877 874 if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) ) 878 if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) ) { 875 879 $global_groups = $wp_object_cache->global_groups; 876 else880 } else { 877 881 $global_groups = false; 882 } 878 883 879 884 wp_cache_init(); 880 885 -
src/wp-includes/ms-functions.php
1966 1966 * 1967 1967 * @since MU 1968 1968 * 1969 * @global int $blog_id1970 *1971 1969 * @param array $details 1972 1970 * @return true|WP_Error|void 1973 1971 */ 1974 1972 function add_existing_user_to_blog( $details = false ) { 1975 global $blog_id;1976 1977 1973 if ( is_array( $details ) ) { 1974 $blog_id = get_current_blog_id(); 1978 1975 $result = add_user_to_blog( $blog_id, $details[ 'user_id' ], $details[ 'role' ] ); 1979 1976 /** 1980 1977 * Fires immediately after an existing user is added to a site. -
src/wp-includes/user.php
965 965 * @since 2.3.0 966 966 * @since 4.5.0 Added the 'display_name_with_login' value for 'show'. 967 967 * 968 * @global int $blog_id969 *970 968 * @param array|string $args { 971 969 * Optional. Array or string of arguments to generate a drop-down of users. 972 970 * See WP_User_Query::prepare_query() for additional available arguments. … … 1016 1014 'include' => '', 'exclude' => '', 'multi' => 0, 1017 1015 'show' => 'display_name', 'echo' => 1, 1018 1016 'selected' => 0, 'name' => 'user', 'class' => '', 'id' => '', 1019 'blog_id' => $GLOBALS['blog_id'], 'who' => '', 'include_selected' => false,1017 'blog_id' => get_current_blog_id(), 'who' => '', 'include_selected' => false, 1020 1018 'option_none_value' => -1 1021 1019 ); 1022 1020