WooCommerce Code Reference

RemoteInboxNotificationsDataSourcePoller extends DataSourcePoller
in package

Specs data source poller class.

This handles polling specs from JSON endpoints, and stores the specs in to the database as an option.

Table of Contents

DATA_SOURCES  = array()
Default data sources array.
FILTER_NAME  = 'data_source_poller_data_sources'
Name of data sources filter.
FILTER_NAME_SPECS  = 'data_source_poller_specs'
Name of data source specs filter.
ID  = 'remote_inbox_notifications'
PUBLISHED_SNAPSHOT_TRANSIENT  = 'woocommerce_admin_remote_inbox_notifications_published_snapshot'
Transient holding the latest read's fetch time and published slugs, or null slugs for an inconclusive read.
$args  : array<string|int, mixed>
Default args.
$data_sources  : array<string|int, mixed>
Default data sources array.
$id  : string
Id of DataSourcePoller.
$instance  : RemoteInboxNotificationsDataSourcePoller
Class instance.
$logger  : WC_Logger|null
The logger instance.
$published_slugs  : array<string|int, string>|null
Published identities from this read's canonical response, or null when it is not authoritative.
__construct()  : mixed
Constructor.
delete_specs_transient()  : bool
Delete the specs transient.
get_cached_specs()  : array<string|int, mixed>
Gets specs from cache if it exists.
get_data_sources()  : array<string|int, mixed>
Get data sources.
get_instance()  : mixed
Get class instance.
get_specs_from_data_sources()  : array<string|int, mixed>
Reads the data sources for specs and persists those specs.
read_specs_from_data_sources()  : bool
Read the data sources and record the identities published by the canonical WooCommerce.com feed.
set_specs_transient()  : mixed
Set the specs transient.
get_logger()  : WC_Logger
Get the logger instance.
get_spec_key()  : string|bool
Returns the key identifier of spec, this can easily be overwritten. Defaults to id.
merge_specs()  : void
Merge runnable specs and track canonical publication identities independently of validation.
read_data_source()  : array<string|int, mixed>
Read a single data source and return the read specs
validate_spec()  : bool
Validate the spec.
save_published_snapshot()  : void
Store a read's publication evidence unless a newer read is already stored.
validate_action()  : bool
Validate the action.

Constants

Properties

Methods

__construct()

Constructor.

public __construct(string $id[, array<string|int, mixed> $data_sources = array() ][, array<string|int, mixed> $args = array() ]) : mixed
Parameters
$id : string

id of DataSourcePoller.

$data_sources : array<string|int, mixed> = array()

urls for data sources.

$args : array<string|int, mixed> = array()

Options for DataSourcePoller.

Return values
mixed —

get_cached_specs()

Gets specs from cache if it exists.

public get_cached_specs() : array<string|int, mixed>
Return values
array<string|int, mixed> — list of specs.

get_specs_from_data_sources()

Reads the data sources for specs and persists those specs.

public get_specs_from_data_sources() : array<string|int, mixed>
Return values
array<string|int, mixed> — list of specs.

read_specs_from_data_sources()

Read the data sources and record the identities published by the canonical WooCommerce.com feed.

public read_specs_from_data_sources() : bool

Invalid specs with usable slugs still count as published. An inconclusive response retains only its timestamp to reject older reads.

Tags
since
11.3.0
Return values
bool — Whether any specs were read.

set_specs_transient()

Set the specs transient.

public set_specs_transient(array<string|int, mixed> $specs, int $expiration) : mixed
Parameters
$specs : array<string|int, mixed>

The specs to set in the transient.

$expiration : int

The expiration time for the transient.

Return values
mixed —

get_spec_key()

Returns the key identifier of spec, this can easily be overwritten. Defaults to id.

protected get_spec_key(mixed $spec) : string|bool
Parameters
$spec : mixed

a JSON parsed spec coming from the JSON feed.

Return values
string|bool —

merge_specs()

Merge runnable specs and track canonical publication identities independently of validation.

protected merge_specs(array<string|int, mixed> $specs_to_merge_in, array<string|int, mixed> &$specs, string $url) : void
Parameters
$specs_to_merge_in : array<string|int, mixed>

The specs to merge in to $specs.

$specs : array<string|int, mixed>

The list of specs being merged into.

$url : string

The url of the feed being merged in.

Tags
since
11.3.0
Return values
void —

read_data_source()

Read a single data source and return the read specs

protected static read_data_source(string $url) : array<string|int, mixed>
Parameters
$url : string

The URL to read the specs from.

Return values
array<string|int, mixed> — The specs that have been read from the data source.

save_published_snapshot()

Store a read's publication evidence unless a newer read is already stored.

private save_published_snapshot(int $fetched_at, array<string|int, string>|null $slugs) : void
Parameters
$fetched_at : int

When the read started.

$slugs : array<string|int, string>|null

Published slugs, or null for an inconclusive read.

Return values
void —