定制 wpdesk/wp-wpdesk-tracker 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

wpdesk/wp-wpdesk-tracker

最新稳定版本:3.7.1

Composer 安装命令:

composer require wpdesk/wp-wpdesk-tracker

包简介

README 文档

README

A WordPress library containing interfaces, abstracts and implementations to be used for plugins' usage tracking.

[[TOC]]

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

Usage

The library features multiple purposes:

  • provides a framework for collecting website usage data,
  • prepares a common set of data to be sent to the tracker server,
  • exposes UI elements for user to interact with the tracker (enable/disable telemetry)

Extending collected data

If you want to include custom data exposed by your plugin, you can easily add it to the usage data payload. There are two ways to register additional data:

  • via wpdesk_tracker_data filter,
  • by registering class implementing WPDesk_Tracker_Data_Provider interface

Exposing to users

As usage tracking is disabled by default, a key point is to encourage users to enable it. This library exposes some common UI interfaces, which serves the purpose of enabling the telemetry:

  • admin notice, encouraging user to enable usage tracking,
  • a box with information about tracking and actionable buttons
/**
 * Assuming usage with wp-builder library.
 */

use WPDesk\Tracker\OptInOptOut;
use WPDesk\Tracker\OptInPage;
use WPDesk\PluginBuilder\Plugin\AbstractPlugin;

class Plugin extends AbstractPlugin {
  public function hooks(): void {
	$tracker_ui = new OptInOptOut(
		$this->plugin_info->get_plugin_file_name(),
		$this->plugin_info->get_plugin_slug(),
		'https://wpdesk.net',
		$this->plugin_info->get_plugin_name()
	);
	$tracker_ui->create_objects();
	$tracker_ui->hooks();
  }

  public function settings_page(): void {
    echo "<h1>Settings page</h1>";

	(new OptInPage(
		$this->plugin_info->get_plugin_file_name(),
		$this->plugin_info->get_plugin_slug()
	))->output();
  }
}

Replacing the default sender

By default, the library sends usage data to wpdesk.org server. You can replace it with your desired endpoint, by swapping WPDesk_Tracker_Sender implementation.

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();
}

Technical details

The library enables usage tracking globally for all library consumers. This means, if you have two separate plugins using the library, the data will be send only once.

After enabling, data collection is performed periodically, once a week.

统计信息

  • 总下载量: 57.24k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 9
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-04-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固