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
Branches initialize-tracker
No related tags found
1 merge request!6feat: initialize usage tracker
Pipeline #341234 passed with stages
in 41 seconds
......@@ -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,21 +58,23 @@ trait TrackerInstanceAsFilterTrait {
$tracker_factory = new \WPDesk_Tracker_Factory_Prefixed();
self::$tracker_instance = $tracker_factory->create_tracker( basename( $this->plugin_info->get_plugin_file_name() ) );
$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();
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(
$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