Changeset 7058
- Timestamp:
- 05/13/2013 02:25:04 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/includes/testcase.php
r7043 r7058 46 46 47 47 function go_to( $url ) { 48 // Set this for bp_core_set_uri_globals()49 $GLOBALS['_SERVER']['REQUEST_URI'] = $url = str_replace( untrailingslashit( network_home_url() ), '', $url );50 51 48 // note: the WP and WP_Query classes like to silently fetch parameters 52 49 // from all over the place (globals, GET, etc), which makes it tricky … … 58 55 $parts = parse_url($url); 59 56 if (isset($parts['scheme'])) { 57 // set the HTTP_HOST 58 $GLOBALS['_SERVER']['HTTP_HOST'] = $parts['host']; 59 60 60 $req = $parts['path']; 61 61 if (isset($parts['query'])) { … … 78 78 } 79 79 80 $_SERVER['REQUEST_URI'] = $req; 80 // Set this for bp_core_set_uri_globals() 81 $GLOBALS['_SERVER']['REQUEST_URI'] = $req; 81 82 unset($_SERVER['PATH_INFO']); 82 83 83 $this->flush_cache(); 84 // setup $current_site and $current_blog globals for multisite based on 85 // REQUEST_URI; mostly copied from /wp-includes/ms-settings.php 86 if ( is_multisite() ) { 87 $domain = addslashes( $_SERVER['HTTP_HOST'] ); 88 if ( false !== strpos( $domain, ':' ) ) { 89 if ( substr( $domain, -3 ) == ':80' ) { 90 $domain = substr( $domain, 0, -3 ); 91 $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -3 ); 92 } elseif ( substr( $domain, -4 ) == ':443' ) { 93 $domain = substr( $domain, 0, -4 ); 94 $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -4 ); 95 } 96 } 97 98 $domain = rtrim( $domain, '.' ); 99 $cookie_domain = $domain; 100 if ( substr( $cookie_domain, 0, 4 ) == 'www.' ) 101 $cookie_domain = substr( $cookie_domain, 4 ); 102 103 $path = preg_replace( '|([a-z0-9-]+.php.*)|', '', $GLOBALS['_SERVER']['REQUEST_URI'] ); 104 $path = str_replace ( '/wp-admin/', '/', $path ); 105 $path = preg_replace( '|(/[a-z0-9-]+?/).*|', '$1', $path ); 106 107 $GLOBALS['current_site'] = wpmu_current_site(); 108 if ( ! isset( $GLOBALS['current_site']->blog_id ) ) 109 $GLOBALS['current_site']->blog_id = $wpdb->get_var( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE domain = %s AND path = %s", $GLOBALS['current_site']->domain, $GLOBALS['current_site']->path ) ); 110 111 // unit tests only support subdirectory install at the moment 112 // removed object cache references 113 if ( ! is_subdomain_install() ) { 114 $blogname = htmlspecialchars( substr( $GLOBALS['_SERVER']['REQUEST_URI'], strlen( $path ) ) ); 115 if ( false !== strpos( $blogname, '/' ) ) 116 $blogname = substr( $blogname, 0, strpos( $blogname, '/' ) ); 117 if ( false !== strpos( $blogname, '?' ) ) 118 $blogname = substr( $blogname, 0, strpos( $blogname, '?' ) ); 119 $reserved_blognames = array( 'page', 'comments', 'blog', 'wp-admin', 'wp-includes', 'wp-content', 'files', 'feed' ); 120 if ( $blogname != '' && ! in_array( $blogname, $reserved_blognames ) && ! is_file( $blogname ) ) 121 $path .= $blogname . '/'; 122 123 $GLOBALS['current_blog'] = get_blog_details( array( 'domain' => $domain, 'path' => $path ), false ); 124 125 unset($reserved_blognames); 126 } 127 128 $GLOBALS['blog_id'] = $GLOBALS['current_blog']->blog_id; 129 } 130 84 131 unset($GLOBALS['wp_query'], $GLOBALS['wp_the_query']); 85 132 $GLOBALS['wp_the_query'] =& new WP_Query(); … … 197 244 } 198 245 199 246 /** 247 * Go to the root blog. This helps reset globals after moving between 248 * blogs. 249 */ 250 public function go_to_root() { 251 $blog_1_url = get_blog_option( 1, 'home' ); 252 $this->go_to( str_replace( $blog_1_url, '', trailingslashit( bp_get_root_domain() ) ) ); 253 } 200 254 }
Note: See TracChangeset
for help on using the changeset viewer.