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

fix: register tracker ui extensions for each plugin


Tracker UI extension has to be registered for each plugin, and doing it
inside filter triggers limits to only one execution.

Signed-off-by: default avatarBart Jaskulski <bjaskulski@protonmail.com>
parent ef0e1d01
No related branches found
No related tags found
1 merge request!6feat: initialize usage tracker
Pipeline #341234 passed
This commit is part of merge request !6. Comments created here will be created in the context of that merge request.
......@@ -55,6 +55,7 @@ class SimpleFreeStrategy implements InitializationStrategy {
// 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;
}
......
......@@ -68,6 +68,7 @@ class SimplePaidStrategy implements InitializationStrategy {
// 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;
......
......@@ -58,6 +58,14 @@ trait TrackerInstanceAsFilterTrait {
$tracker_factory = new \WPDesk_Tracker_Factory_Prefixed();
self::$tracker_instance = $tracker_factory->create_tracker( basename( $this->plugin_info->get_plugin_file_name() ) );
do_action( 'wpdesk_tracker_started', self::$tracker_instance, $this->plugin_info );
return self::$tracker_instance;
}
}, 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(
......@@ -68,11 +76,5 @@ trait TrackerInstanceAsFilterTrait {
);
$tracker_ui->create_objects();
$tracker_ui->hooks();
do_action( 'wpdesk_tracker_started', self::$tracker_instance, $this->plugin_info );
return self::$tracker_instance;
}
}, 10 - $this->get_tracker_version() );
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment