Changeset 38681
- Timestamp:
- 09/30/2016 04:09:45 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/ms-load.php
r38515 r38681 138 138 * 139 139 * @since 3.9.0 140 * @since 4.7.0 Updated to always return a `WP_Site` object. 140 141 * 141 142 * @global wpdb $wpdb WordPress database abstraction object. … … 144 145 * @param string $path Path to check. 145 146 * @param int|null $segments Path segments to use. Defaults to null, or the full path. 146 * @return object|false Site object if successful. False when no site is found.147 * @return WP_Site|false Site object if successful. False when no site is found. 147 148 */ 148 149 function get_site_by_path( $domain, $path, $segments = null ) { … … 187 188 * @since 3.9.0 188 189 * 189 * @param null|bool| object$site Site value to return by path.190 * @param string $domain The requested domain.191 * @param string $path The requested path, in full.192 * @param int|null $segments The suggested number of paths to consult.193 * Default null, meaning the entire path was to be consulted.194 * @param array $paths The paths to search for, based on $path and $segments.190 * @param null|bool|WP_Site $site Site value to return by path. 191 * @param string $domain The requested domain. 192 * @param string $path The requested path, in full. 193 * @param int|null $segments The suggested number of paths to consult. 194 * Default null, meaning the entire path was to be consulted. 195 * @param array $paths The paths to search for, based on $path and $segments. 195 196 */ 196 197 $pre = apply_filters( 'pre_get_site_by_path', null, $domain, $path, $segments, $paths ); 197 198 if ( null !== $pre ) { 199 if ( false !== $pre && ! $pre instanceof WP_Site ) { 200 $pre = new WP_Site( $pre ); 201 } 198 202 return $pre; 199 203 } -
trunk/tests/phpunit/tests/multisite/bootstrap.php
r37475 r38681 209 209 } 210 210 211 /** 212 * @ticket 37053 213 */ 214 public function test_get_site_by_path_returns_wp_site() { 215 add_filter( 'pre_get_site_by_path', array( $this, 'filter_pre_get_site_by_path' ), 10, 3 ); 216 217 $site = get_site_by_path( 'example.com', '/foo/' ); 218 219 remove_filter( 'pre_get_site_by_path', array( $this, 'filter_pre_get_site_by_path' ), 10 ); 220 221 $this->assertInstanceOf( 'WP_Site', $site ); 222 } 223 211 224 public function filter_path_segments_to_two() { 212 225 return 2; 213 226 } 227 228 public function filter_pre_get_site_by_path( $site, $domain, $path ) { 229 $site = new stdClass(); 230 $site->blog_id = 100; 231 $site->domain = $domain; 232 $site->path = $path; 233 $site->site_id = 1; 234 235 return $site; 236 } 214 237 } 215 238
Note: See TracChangeset
for help on using the changeset viewer.