PTKPatternsStore
in package
PTKPatterns class.
Table of Contents
- EXCLUDED_PATTERNS = array('13923', '14781', '14779', '13666', '13664', '13660', '13588', '14922', '14880', '13596', '13967', '13958', '15050', '15027')
- TRANSIENT_NAME = 'ptk_patterns'
- $ptk_client : PTKClient
- PatternsToolkit instance.
- __construct() : mixed
- Constructor for the class.
- fetch_patterns() : void
- Reset the cached patterns and fetch them again from the PTK API.
- fetch_patterns_on_plugin_update() : void
- Re-fetch the patterns when the WooCommerce plugin is updated.
- flush_cached_patterns() : void
- Reset the cached patterns to fetch them again from the PTK.
- flush_or_fetch_patterns() : void
- Resets the cached patterns when the `woocommerce_allow_tracking` option is disabled.
- get_patterns() : array<string|int, mixed>
- Get the patterns from the Patterns Toolkit cache.
- allowed_tracking_is_enabled() : bool
- Check if the user allowed tracking.
- filter_patterns() : array<string|int, mixed>
- Filter patterns to exclude those with the given IDs.
- schedule_action_if_not_pending() : void
- Schedule an action if it's not already pending.
- schedule_fetch_patterns() : void
- Schedule an async action to fetch the PTK patterns when the scheduler is initialized.
Constants
EXCLUDED_PATTERNS
public
mixed
EXCLUDED_PATTERNS
= array('13923', '14781', '14779', '13666', '13664', '13660', '13588', '14922', '14880', '13596', '13967', '13958', '15050', '15027')
TRANSIENT_NAME
public
mixed
TRANSIENT_NAME
= 'ptk_patterns'
Properties
$ptk_client
PatternsToolkit instance.
private
PTKClient
$ptk_client
Methods
__construct()
Constructor for the class.
public
__construct(PTKClient $ptk_client) : mixed
Parameters
- $ptk_client : PTKClient
-
An instance of PatternsToolkit.
Return values
mixed —fetch_patterns()
Reset the cached patterns and fetch them again from the PTK API.
public
fetch_patterns() : void
Return values
void —fetch_patterns_on_plugin_update()
Re-fetch the patterns when the WooCommerce plugin is updated.
public
fetch_patterns_on_plugin_update(WP_Upgrader $upgrader_object, array<string|int, mixed> $options) : void
Parameters
- $upgrader_object : WP_Upgrader
-
WP_Upgrader instance.
- $options : array<string|int, mixed>
-
Array of bulk item update data.
Return values
void —flush_cached_patterns()
Reset the cached patterns to fetch them again from the PTK.
public
flush_cached_patterns() : void
Return values
void —flush_or_fetch_patterns()
Resets the cached patterns when the `woocommerce_allow_tracking` option is disabled.
public
flush_or_fetch_patterns() : void
Resets and fetch the patterns from the PTK when it is enabled (if the scheduler is initialized, it's done asynchronously via a scheduled action).
Return values
void —get_patterns()
Get the patterns from the Patterns Toolkit cache.
public
get_patterns() : array<string|int, mixed>
Return values
array<string|int, mixed> —allowed_tracking_is_enabled()
Check if the user allowed tracking.
private
allowed_tracking_is_enabled() : bool
Return values
bool —filter_patterns()
Filter patterns to exclude those with the given IDs.
private
filter_patterns(array<string|int, mixed> $patterns, array<string|int, mixed> $pattern_ids) : array<string|int, mixed>
Parameters
- $patterns : array<string|int, mixed>
-
The patterns to filter.
- $pattern_ids : array<string|int, mixed>
-
The pattern IDs to exclude.
Return values
array<string|int, mixed> —schedule_action_if_not_pending()
Schedule an action if it's not already pending.
private
schedule_action_if_not_pending(string $action) : void
Parameters
- $action : string
-
The action name to schedule.
Return values
void —schedule_fetch_patterns()
Schedule an async action to fetch the PTK patterns when the scheduler is initialized.
private
schedule_fetch_patterns() : void