wp/wp-includes/class-wp-network.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
    99 			return false;
    99 			return false;
   100 		}
   100 		}
   101 
   101 
   102 		$_network = wp_cache_get( $network_id, 'networks' );
   102 		$_network = wp_cache_get( $network_id, 'networks' );
   103 
   103 
   104 		if ( ! $_network ) {
   104 		if ( false === $_network ) {
   105 			$_network = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->site} WHERE id = %d LIMIT 1", $network_id ) );
   105 			$_network = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->site} WHERE id = %d LIMIT 1", $network_id ) );
   106 
   106 
   107 			if ( empty( $_network ) || is_wp_error( $_network ) ) {
   107 			if ( empty( $_network ) || is_wp_error( $_network ) ) {
   108 				return false;
   108 				$_network = -1;
   109 			}
   109 			}
   110 
   110 
   111 			wp_cache_add( $network_id, $_network, 'networks' );
   111 			wp_cache_add( $network_id, $_network, 'networks' );
       
   112 		}
       
   113 
       
   114 		if ( is_numeric( $_network ) ) {
       
   115 			return false;
   112 		}
   116 		}
   113 
   117 
   114 		return new WP_Network( $_network );
   118 		return new WP_Network( $_network );
   115 	}
   119 	}
   116 
   120 
   229 
   233 
   230 		if ( 0 < (int) $this->blog_id ) {
   234 		if ( 0 < (int) $this->blog_id ) {
   231 			return (int) $this->blog_id;
   235 			return (int) $this->blog_id;
   232 		}
   236 		}
   233 
   237 
   234 		if ( ( defined( 'DOMAIN_CURRENT_SITE' ) && defined( 'PATH_CURRENT_SITE' ) && $this->domain === DOMAIN_CURRENT_SITE && $this->path === PATH_CURRENT_SITE )
   238 		if ( ( defined( 'DOMAIN_CURRENT_SITE' ) && defined( 'PATH_CURRENT_SITE' ) && DOMAIN_CURRENT_SITE === $this->domain && PATH_CURRENT_SITE === $this->path )
   235 			|| ( defined( 'SITE_ID_CURRENT_SITE' ) && $this->id == SITE_ID_CURRENT_SITE ) ) {
   239 			|| ( defined( 'SITE_ID_CURRENT_SITE' ) && SITE_ID_CURRENT_SITE == $this->id ) ) {
   236 			if ( defined( 'BLOG_ID_CURRENT_SITE' ) ) {
   240 			if ( defined( 'BLOG_ID_CURRENT_SITE' ) ) {
   237 				$this->blog_id = (string) BLOG_ID_CURRENT_SITE;
   241 				$this->blog_id = (string) BLOG_ID_CURRENT_SITE;
   238 
   242 
   239 				return (int) $this->blog_id;
   243 				return (int) $this->blog_id;
   240 			}
   244 			}
   241 
   245 
   242 			if ( defined( 'BLOGID_CURRENT_SITE' ) ) { // deprecated.
   246 			if ( defined( 'BLOGID_CURRENT_SITE' ) ) { // Deprecated.
   243 				$this->blog_id = (string) BLOGID_CURRENT_SITE;
   247 				$this->blog_id = (string) BLOGID_CURRENT_SITE;
   244 
   248 
   245 				return (int) $this->blog_id;
   249 				return (int) $this->blog_id;
   246 			}
   250 			}
   247 		}
   251 		}
   401 		 * can be found at the requested domain and path. Otherwise, return
   405 		 * can be found at the requested domain and path. Otherwise, return
   402 		 * an object from wp_get_network().
   406 		 * an object from wp_get_network().
   403 		 *
   407 		 *
   404 		 * @since 3.9.0
   408 		 * @since 3.9.0
   405 		 *
   409 		 *
   406 		 * @param null|bool|WP_Network $network  Network value to return by path.
   410 		 * @param null|bool|WP_Network $network  Network value to return by path. Default null
       
   411 		 *                                       to continue retrieving the network.
   407 		 * @param string               $domain   The requested domain.
   412 		 * @param string               $domain   The requested domain.
   408 		 * @param string               $path     The requested path, in full.
   413 		 * @param string               $path     The requested path, in full.
   409 		 * @param int|null             $segments The suggested number of paths to consult.
   414 		 * @param int|null             $segments The suggested number of paths to consult.
   410 		 *                                       Default null, meaning the entire path was to be consulted.
   415 		 *                                       Default null, meaning the entire path was to be consulted.
   411 		 * @param string[]             $paths    Array of paths to search for, based on `$path` and `$segments`.
   416 		 * @param string[]             $paths    Array of paths to search for, based on `$path` and `$segments`.
   455 				if ( in_array( $network->path, $paths, true ) ) {
   460 				if ( in_array( $network->path, $paths, true ) ) {
   456 					$found = true;
   461 					$found = true;
   457 					break;
   462 					break;
   458 				}
   463 				}
   459 			}
   464 			}
   460 			if ( $network->path === '/' ) {
   465 			if ( '/' === $network->path ) {
   461 				$found = true;
   466 				$found = true;
   462 				break;
   467 				break;
   463 			}
   468 			}
   464 		}
   469 		}
   465 
   470