Automattic\WooCommerce\Blocks\Patterns
PTKPatternsStore::__construct
Constructor for the class.
Method of the class: PTKPatternsStore{}
No Hooks.
Returns
null
. Nothing (null).
Usage
$PTKPatternsStore = new PTKPatternsStore(); $PTKPatternsStore->__construct( $ptk_client );
- $ptk_client(PTKClient) (required)
- An instance of PatternsToolkit.
PTKPatternsStore::__construct() PTKPatternsStore:: construct code WC 9.9.4
public function __construct( PTKClient $ptk_client ) { $this->ptk_client = $ptk_client; if ( Features::is_enabled( 'pattern-toolkit-full-composability' ) ) { // We want to flush the cached patterns when: // - The WooCommerce plugin is deactivated. // - The `woocommerce_allow_tracking` option is disabled. // // We also want to re-fetch the patterns and update the cache when: // - The `woocommerce_allow_tracking` option changes to enabled. // - The WooCommerce plugin is activated (if `woocommerce_allow_tracking` is enabled). // - The WooCommerce plugin is updated. add_action( 'woocommerce_activated_plugin', array( $this, 'flush_or_fetch_patterns' ), 10, 2 ); add_action( 'update_option_woocommerce_allow_tracking', array( $this, 'flush_or_fetch_patterns' ), 10, 2 ); add_action( 'deactivated_plugin', array( $this, 'flush_cached_patterns' ), 10, 2 ); add_action( 'upgrader_process_complete', array( $this, 'fetch_patterns_on_plugin_update' ), 10, 2 ); // This is the scheduled action that takes care of flushing and re-fetching the patterns from the PTK API. add_action( 'fetch_patterns', array( $this, 'fetch_patterns' ) ); } }