Skip to main content

Site

Site class represents a WordPress multisite Site and Blog pair, and provides access to their properties and metadata.


Description

  • Encapsulates a site and its associated blog from the WordPress database.
  • Automatically initializes site and blog data using QueryUtil.
  • Throws an error if the blog does not belong to the specified site.
  • Updates Meta context with the site ID.

Properties

props
props: {
site: Partial<types.Tables["site"]>;
blog: Partial<types.Tables["blogs"]> & { blog_id: number };
}

Returns the current loaded state of the site and blog data.


Methods

setBlog
setBlog(b: number | string): Promise<void>

Fetches and updates the current blog by ID or domain. Throws if the blog’s site_id does not match the current site.


Lifecycle

init (decorated with @asyncInit)
private init(): Promise<void>

Asynchronously initializes the site and blog properties via QueryUtil, and sets the Meta context.