Skip to content
Snippets Groups Projects
Verified Commit 94e70bf5 authored by Bartek Jaskulski's avatar Bartek Jaskulski
Browse files

Merge branch 'initialize-tracker'

parents 24114b93 233d6e6f
No related branches found
Tags 1.2.0 1.2.0-beta.1
1 merge request!6feat: initialize usage tracker
Pipeline #341748 failed with stages
in 55 seconds
## [Unreleased]
### Changed
- Usage tracker is initialized by the library after all plugin's hookables are registered.
## [1.1.0] - 2022-11-23
### Added
- Compatibility with WooCommerce High-Performance Order Storage (HPOS)
......
......@@ -52,6 +52,10 @@ class SimpleFreeStrategy implements InitializationStrategy {
$this->store_plugin( $this->plugin );
$this->init_plugin( $this->plugin );
// Flush usage tracker late, to remain backward compatible with plugins which could instantiate
// the tracker on their own through `wpdesk_tracker_instance` filter.
$this->get_tracker_instance();
$this->register_tracker_ui_extensions();
return $this->plugin;
}
......
......@@ -65,6 +65,10 @@ class SimplePaidStrategy implements InitializationStrategy {
}
$this->store_plugin( $this->plugin );
$this->init_plugin( $this->plugin );
// Flush usage tracker late, to remain backward compatible with plugins which could instantiate
// the tracker on their own through `wpdesk_tracker_instance` filter.
$this->get_tracker_instance();
$this->register_tracker_ui_extensions();
}, $priority_before_flow_2_5_after_2_6 = -45);
return $this->plugin;
......
......@@ -3,6 +3,8 @@
namespace WPDesk\Plugin\Flow\Initialization\Simple;
use WPDesk\Tracker\OptInOptOut;
/**
* Trait helps with tracker initialization
*
......@@ -62,4 +64,17 @@ trait TrackerInstanceAsFilterTrait {
}
}, 10 - $this->get_tracker_version() );
}
private function register_tracker_ui_extensions() {
$shops = $this->plugin_info->get_plugin_shops();
$shop_url = $shops[ get_locale() ] ?? ( $shops['default'] ?? 'https://wpdesk.net' );
$tracker_ui = new OptInOptOut(
$this->plugin_info->get_plugin_file_name(),
$this->plugin_info->get_plugin_slug(),
$shop_url,
$this->plugin_info->get_plugin_name()
);
$tracker_ui->create_objects();
$tracker_ui->hooks();
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment