Switches to the blog requested in the request
@param string|integer|null $site_name_or_id
@return integer with the ID of the new blog
178223
protected static function switch_to_blog( $site_name_or_id ) {
		if ( $site_name_or_id === null ) {
			$site_name_or_id = get_current_blog_id();
		}
		$info = get_blog_details($site_name_or_id);
		switch_to_blog($info->blog_id);
		return $info->blog_id;
	}
485841
protected function check_object_id( $object_id ) {
		$fetcher = new SiteFetcher();
		$site    = $fetcher->get_check( $object_id );
		return $site->blog_id;
	}
644443
static function get_manager( $id, $load = false, $network_level_or_blog_id = false ) {
            $key = strtolower( $id );

            if ( is_multisite() ) {
                if ( true === $network_level_or_blog_id ) {
                    $key .= ':ms';
                } else if ( is_numeric( $network_level_or_blog_id ) && $network_level_or_blog_id > 0 ) {
                    $key .= ":{$network_level_or_blog_id}";
                } else {
                    $network_level_or_blog_id = get_current_blog_id();

                    $key .= ":{$network_level_or_blog_id}";
                }
            }

            if ( ! isset( self::$_MANAGERS[ $key ] ) ) {
                self::$_MANAGERS[ $key ] = new FS_Option_Manager( $id, $load, $network_level_or_blog_id );
            } // If load required but not yet loaded, load.
            else if ( $load && ! self::$_MANAGERS[ $key ]->is_loaded() ) {
                self::$_MANAGERS[ $key ]->load();
            }

            return self::$_MANAGERS[ $key ];
        }
501832
public function getPageByName(
        SiteEntity $site,
        $pageName,
        $pageType = PageTypes::NORMAL
    ) {
        $results = $this->getPagesByName(
            $site,
            $pageName,
            $pageType
        );

        if (empty($results)) {
            return null;
        }

        return $results[0];
    }
956756
protected function getNewSiteDoman($options, $site_name) {
    if (empty($options['site-uri'])) {
      $domain = $this->askDefault("Local domain name",
        "http://local.$site_name.com");
    }
    else {
      $domain = $options['site-uri'];
    }
    return $domain;
  }
177295
public function setSiteId(int $nb_site_id) : CNabuDataObject
    {
        if ($nb_site_id === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$nb_site_id")
            );
        }
        $this->setValue('nb_site_id', $nb_site_id);
        
        return $this;
    }
695020
private static function is_site_active( $blog_id ) {
            global $wpdb;

            $blog_info = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->blogs} WHERE blog_id = %d", $blog_id ) );

            if ( ! is_object( $blog_info ) ) {
                return false;
            }

            return (
                true == $blog_info->public &&
                false == $blog_info->archived &&
                false == $blog_info->mature &&
                false == $blog_info->spam &&
                false == $blog_info->deleted
            );
        }
34733
protected function getSiteByName($sites, $site_name)
    {
        $site_found = collect($sites)->filter(function ($site) use ($site_name) {
            return $site->name === $site_name;
        })->first();

        if ($site_found) {
            return $site_found;
        }
        return null;
    }
627700
private function get_site( $site_id ) {
		global $wpdb;

		// Load site data
		$site = $wpdb->get_row(
			$wpdb->prepare(
				"SELECT * FROM {$wpdb->blogs} WHERE blog_id = %d",
				$site_id
			)
		);

		if ( ! empty( $site ) ) {
			// Only care about domain and path which are set here
			return $site;
		}

		return false;
	}
712976
def blog__get_post(id: nil, permalink: nil)
      return {} unless id || permalink

      if id
        post = LatoBlog::Post.find_by(id: id.to_i, meta_status: 'published')
      else
        post = LatoBlog::Post.find_by(meta_permalink: permalink, meta_status: 'published')
      end

      post.serialize
    end
160677
private function get_site_notices( $blog_id = 0 ) {
            if ( 0 == $blog_id || $blog_id == $this->_blog_id ) {
                return $this->_notices;
            }

            return FS_Admin_Notice_Manager::instance(
                $this->_id,
                $this->_title,
                $this->_module_unique_affix,
                false,
                $blog_id
            );
        }
763584
public function getSiteNotAvailableRedirectUrl(Site $site)
    {
        if ($site->isSiteAvailable()) {
            return null;
        }

        $defaultDomain = $this->domainService->getDefaultDomainName();

        if (empty($defaultDomain)) {
            return null;
        }

        if ($defaultDomain == $site->getDomain()->getDomainName()) {
            return null;
        }

        return $defaultDomain;
    }
1215800
private function skip_site_connection( $blog_id = null, $send_skip = true ) {
            $this->_logger->entrance();

            $this->_admin_notices->remove_sticky( 'connect_account', $blog_id );

            $this->set_anonymous_mode( true, $blog_id );

            if ( $send_skip ) {
                $this->get_api_plugin_scope()->call( 'skip.json', 'put', array(
                    'uids' => array( $this->get_anonymous_id( $blog_id ) ),
                ) );
            }
        }
1353930
static function get_site_blog_id( &$site ) {
            return ( $site instanceof WP_Site ) ?
                $site->blog_id :
                ( is_object( $site ) && isset( $site->userblog_id ) ?
                    $site->userblog_id :
                    $site['blog_id'] );
        }
687767
public function get(
        $root = null,
        $siteId = null,
        $pages = null,
        $pageType = null,
        $pageName = null
    ) {
        if (empty($root)) {
            $root = self::RESOURCE_SITES;
        }

        if (empty($siteId)) {
            return $root;
        }

        if (empty($pages)) {
            return $root . '.' . $siteId;
        }

        if (empty($pageType) || empty($pageName)) {
            return $root . '.' . $siteId . '.' . $pages;
        }

        return $root . '.' . $siteId . '.' . $pages . '.' . $pageType . '.' . $pageName;
    }
603397
@CheckForNull
    public UpdateSite getById(String id) {
        for (UpdateSite s : sites) {
            if (s.getId().equals(id)) {
                return s;
            }
        }
        return null;
    }
671018
static function getFirst( $return_post_id = false, $admin_mode = false ) {

		global $blog_id;

		$book_structure = static::getBookStructure();
		$order = $book_structure['__order'];
		$pos = array_keys( $order );

		reset( $pos );
		while ( $first_id = current( $pos ) ) {
			if ( $admin_mode ) {
				if ( current_user_can( 'edit_post', $first_id ) ) {
					break;
				} else {
					next( $pos );
				}
			} else {
				if ( in_array( $order[ $first_id ]['post_status'], [ 'publish', 'web-only' ], true ) ) {
					break;
				} elseif ( current_user_can_for_blog( $blog_id, 'read_private_posts' ) ) {
					break;
				} elseif ( get_option( 'permissive_private_content' ) && current_user_can_for_blog( $blog_id, 'read' ) ) {
					break;
				} else {
					next( $pos );
				}
			}
		}

		if ( $return_post_id ) {
			return (int) $first_id;
		} else {
			return ( empty( $first_id ) ) ? '/' : get_permalink( $first_id );
		}

	}