Recent

Sitewide_DatabaseclassPro only

Sitewide_Database

Maps the built-in site-wide contexts to reserved post-number IDs.

Site-wide counts use the existing Top 10 count, daily, funnel and visits-log tables. The IDs are deliberately outside the normal WordPress post-ID range and are fixed, so no registry table or per-site allocation query is needed.

Namespace: WebberZone\Top_Ten\Pro
Since: 4.5.0
Source: includes/pro/class-sitewide-database.php line 23

Methods

filter_count() static

Provide site-wide counts to the shared database facade.

Since: 4.5.0
Line: 37

static public function filter_count( $count, $context, $blog_id = ..., $daily = ..., $date_range = ... ): int;
Type Name Description
int $count Existing count.
string $context Site-wide context key.
int|null $blog_id Blog ID.
bool $daily Whether to query daily counts.
array $date_range Date range for daily counts.

Returns: int — Site-wide count.

filter_context_ids() static

Provide reserved site-wide IDs to shared orphan cleanup routines.

Since: 4.5.0
Line: 53

static public function filter_context_ids( $context_ids ): array;
Type Name Description
array $context_ids Existing reserved IDs.

Returns: array — Reserved context IDs.

is_available() static

Determine whether the Pro site-wide feature is available.

Line: 99

static public function is_available(  ): bool;

Returns: bool — True when the current installation can use Pro code.

get_context_id() static

Get the numeric ID for a context.

Line: 114

static public function get_context_id( $context, $blog_id = ... ): int;
Type Name Description
string $context Context key.
int|null $blog_id Unused; retained for API compatibility.

Returns: int — Numeric context ID, or 0 for an unknown context.

get_context_ids() static

Return all reserved context IDs.

Line: 126

static public function get_context_ids(  ): array<int,int>;

Returns: array<int,int> — Reserved context IDs.

get_count() static

Get the count for a site-wide context.

Line: 139

static public function get_count( $context, $blog_id = ..., $daily = ..., $date_range = ... ): int;
Type Name Description
string $context Context key.
int&#124;null $blog_id Blog ID.
bool $daily Whether to query daily counts.
array $date_range Date range for daily counts.

Returns: int — Count.

record_view() static

Record one site-wide view in the shared Top 10 tables.

Line: 157

static public function record_view( $context, $blog_id, $activate_counter = ..., $source = ... ): int|false;
Type Name Description
string $context Context key.
int $blog_id Blog ID.
int $activate_counter Counter flag.
int $source Traffic source.

Returns: int|false — Number of affected rows or false on failure.

update_counts_direct() static

Update site-wide counts directly using the shared count tables.

Line: 174

static public function update_counts_direct( $context, $blog_id, $activate_counter = ... ): int|false;
Type Name Description
string $context Context key.
int $blog_id Blog ID.
int $activate_counter Counter flag.

Returns: int|false — Number of affected rows or false on failure.

append_to_funnel() static

Append a site-wide view to the shared funnel.

Line: 192

static public function append_to_funnel( $context, $blog_id, $activate_counter = ..., $source = ... ): int|false;
Type Name Description
string $context Context key.
int $blog_id Blog ID.
int $activate_counter Counter flag.
int $source Traffic source.

Returns: int|false — Number of inserted rows or false on failure.

get_context_key() static

Return a context key for a numeric context ID.

Line: 208

static public function get_context_key( $context_id, $blog_id = ... ): string;
Type Name Description
int $context_id Numeric context ID.
int&#124;null $blog_id Unused; retained for API compatibility.

Returns: string — Context key, or an empty string.

get_context_label() static

Get the translated label for a site-wide context.

Line: 222

static public function get_context_label( $context ): string;
Type Name Description
string $context Context key.

Returns: string — Context label, or an empty string for an unknown context.

is_context_id() static

Determine whether a numeric ID belongs to a reserved context.

Line: 248

static public function is_context_id( $context_id, $blog_id = ... ): bool;
Type Name Description
int $context_id Numeric context ID.
int&#124;null $blog_id Unused; retained for API compatibility.

Returns: bool — True when the ID is reserved.

get_top_contexts() static

Get the most-viewed site-wide contexts for a blog.

Line: 261

static public function get_top_contexts( $limit = ..., $blog_id = ..., $daily = ..., $date_range = ... ): array;
Type Name Description
int $limit Maximum contexts to return.
int&#124;null $blog_id Blog ID.
bool $daily Whether to use daily counts.
array $date_range Optional date range for daily counts.

Returns: array — List of context rows.

normalize_context() static

Normalize a context key before use.

Line: 304

static public function normalize_context( $context ): string;
Type Name Description
string $context Raw context.

Returns: string — Normalized context key, or an empty string.