Ejemplo n.º 1
0
    function site($id = null) {

      if (is_multisite()) {
        
        $sites = $this->sites(array("public_only" => false));
      
        if ($id == null) {
          global $blog_id;
          $id = $blog_id;
        }
      
        if ($id) {
          foreach ($sites as $site) {
            if ($site->id() == $id) {
              return $site;
            }
          }
        }
      } else {

        $url = $this->site_url();
        
        $admin_email = get_bloginfo("admin_email");
        
        $admin = $this->user_by_email($admin_email);
        
        
        // mockup an object that represents the site, with a structure that mirrors what would be returned in the multisite environment
        $site = new stdClass();
        
        $site->blog_id = 1;
        $site->site_id = 1;
        $site->domain = WOOF::domain_of_url($url);
        $site->path = "/";
        
        if ($admin) {
          $site->registered = $admin->registered("Ymd H:i:s");
          $site->last_updated = $admin->registered("Ymd H:i:s");
        }

        $site->public = get_option("blog_public");
        $site->archived = 0;
        $site->mature = 0;
        $site->spam = 0;
        $site->deleted = 0;
        $site->lang_id = get_option("language");
        $site->email = $admin_email;
        $site->ip = '';
        
        return $this->wrap_site($site);
        
      }
      
      return new WOOF_Silent( __("Could not find a site with id $id", WOOF_DOMAIN ) );
    }