插件文件

每个插件都有一个特殊的文件PluginName.php美元哪里需要更换PluginName美元使用插件的名称。例如,如果插件的名称是CustomAlerts,则该文件为插件/ CustomAlerts / CustomAlerts.php.任何这样的插件类都需要扩展Piwik \插件

名称空间Piwik \ Plugins \ CustomAlerts;类CustomAlerts extends \Piwik\Plugin {}

这样的文件不需要存在于插件中,但大多数插件都有这样的文件,因为它们正在监听事件

插件钩子

在每个插件类中都可以覆盖一些特殊的方法。

有关以下钩子和所有可用插件方法的详细信息,请参阅插件API参考

//允许您收听Matomo事件。公共函数registerEvents():数组;//定义整个插件是否需要internet连接。如果设置为true,如果' enable_internet_features '为0,即使插件被激活,插件也会自动卸载。公共函数requiresInternetConnection(): bool;//如果你想让你的插件在跟踪过程中被加载,在你的插件类中重写这个方法。如果你定义了自己的维度或者监听了跟踪事件,你的插件会被自动检测为跟踪插件。公共函数isTrackerPlugin(): bool;//插件安装时执行用于创建或更新DB表或设置配置。 public function install(); // Executed every time the plugin is activated. public function activate(); // Executed on every request after a plugin was loaded. public function postLoad(); // Executed every time the plugin is deactivated. public function deactivate(); // Executed when the plugin is being uninstalled. Useful to undo everything that was done in the install hook like removing a DB table. public function uninstall();

如果你的插件需要改变数据库模式,那么你也可以找到我们的扩展数据库指南有用的。

Baidu