API / Minn\Content / Site

Site final readonly class

Minn\Content\Site · public/minn/src/Minn/Content/Site.php · 114 lines

Site-wide options and the site's clock.

Constants and properties

privatereadonly Minn\Db $db

Promoted from the constructor.

Public

new__construct(Minn\Db $db)#
methodoption(string $name): ?string#

One option's raw value, or null when it is unset.

methodsetOption(string $name, string $value, ?string $autoload = NULL): void#

Writes an option, inserting it as autoloaded when it does not exist; the option store hears of it. An $autoload given is written too, so a cache the engine reads on demand (autoload "off") stays out of the list every request loads.

methoddeleteOption(string $name): void#

Removes an option row; the option store hears of it.

methoddefaultDiscussion(string $type, string $kind): string#

A new post's comment or ping status, as the reference picks it: a post follows the site's two defaults, an attachment follows the comment default and never takes pings, a page and every other type start closed; with plugins loaded, get_default_comment_status() decides (support a plugin removed, the filter). $kind is "comment" or "pingback".

methodtimezone(): DateTimeZone#

The site's timezone (wp_timezone): the zone timezone_string names, else gmt_offset as a fixed offset. With a zone set, the stored gmt_offset is not read at all, as the reference does not read it.

methodgmtOffset(): int#

The site's offset from UTC in seconds now: the zone's, daylight saving included, or gmt_offset's.

methodlocalNow(): string#

Now in the site's local time, MySQL format.

methodlocalDate(string $input): array#

A site-local datetime from a write body ("2031-01-01T00:00:00") to the pair of columns it fills, plus its timestamp.

@return array{0: string, 1: string, 2: int} local, gmt, timestamp
methodgmtDate(string $input): array#

A GMT datetime from a write body (date_gmt) to the same pair of columns, its local half in the site's zone at that date.

@return array{0: string, 1: string, 2: int} local, gmt, timestamp