wpdesk/wp-wpdesk-tracker-deactivation

1.5.2 2022-08-30 08:43 UTC

This package is auto-updated.

Last update: 2024-04-29 04:19:44 UTC


README

pipeline status coverage report Latest Stable Version Total Downloads License

Deactivation Tracker

A WordPress Library containing interfaces, abstracts and implementations to be used for plugin deactivations data tracking.

Requirements

PHP 7.0 or later.

Installation via Composer

In order to install the bindings via Composer run the following command:

composer require wpdesk/wp-wpdesk-tracker-deactivation

Example usage

Creating deactivation tracker

The following code creates deactivation tracker. Once the site admin deactivates the plugin, a pop-up containing the deactivation reasons will appear. Right after the relevant deactivation reason is selected, the site admin's response will be sent to the tracker server.

$deactivation_tracker = \WPDesk\Tracker\Deactivation\TrackerFactory::createDefaultTracker(
	'my-beautiful-plugin',
	'my-beautiful-plugin/my-beautiful-plugin.php',
	__( 'My Beautiful Plugin' )
);
$deactivation_tracker->hooks();

Replacing the default sender

class MySender implements WPDesk_Tracker_Sender {
	public function send_payload(array $payload){
	   // implement send_payload method.
	}
}

$plugin_slug = 'my-example-plugin';
add_filter( 'wpdesk/tracker/sender/' . $plugin_slug, 'replace_sender' );

function replace_sender() {
	return new MySender();
}