內容簡介
如果你是一個 WordPress 的外掛程式開發人員,你的外掛程式很有可能可從 WordPress 的外掛程式庫下載。作為這種服務的一部分,WordPress 的好心人會顯示你每天的外掛程式下載量。這非常有用,如果你像我一樣,你會經常檢查你的下載數字。
然而,這些統計數據沒有顯示你的外掛程式在哪里使用 - 也就是說它實際上被啟用的網站。看到這些信息將允許你確切地看到哪些網站正在使用你的外掛程式,以及他們是何時安裝它,以及該網站運行的版本是什麼。這正是插件註冊者(Plugin Register)的作用。
通過包括 Plugin_Register 類別並在你的外掛程式中調用一些簡單的代碼,當網站啟用時,你的外掛程式會提示用戶註冊你的外掛程式。當他們註冊外掛程式時,你的網站的 Plugin_Register 資料庫將被更新,包括你的外掛程式的名稱和版本,以及剛剛啟用該外掛程式的網站的站名和 URL。向你的網站發送一個簡單的調用,以將這些詳細信息保存在 Plugin_Register 表格中,你就可以獲得一些關於哪些網站正在安裝你的外掛程式的版本的統計數據。
因此,你需要在你的外掛程式中放置些什麼?下面是你需要的範例代碼:
` // 包括 Plugin_Register 類別
require_once("plugin-register.class.php");
// 創建一個 Plugin_Register 類別的新實例
$register = new Plugin_Register(); // 將其保留在原樣
$register->file = FILE; // 將其保留在原樣
$register->slug = "pluginregister"; // 為你的外掛創建一個唯一的 slug(通常是無空格和特殊字符的小寫外掛名稱)
$register->name = "Plugin Register"; // 你的外掛程式的完整名稱(這將顯示在你的統計信息中)
$register->version = "1.0"; // 你的外掛程式的版本(這將顯示在你的統計信息中)
$register->developer = "Chris Taylor"; // 你的名字
$register->homepage = "http://www.stillbreathing.co.uk"; // 你的 WordPress 網站,Plugin_Register 安裝在此處(沒有尾斜線)
$register->Plugin_Register(); // 當該外掛程式啟用時,設置 Plugin Register 的呼叫
你收到的報告包括:
顯示最近 24 小時、14 天、12 周和 12 個月的註冊次數的圖表
所有已註冊的外掛程式列表,包括多少個獨特版本和獨特網站
特定外掛程式所有版本的列表,以及獨特網站的數量
所有註冊了任何你的外掛程式的網站的列表
當天註冊的所有外掛程式的詳細信息
一個搜尋。這樣你就可以看到哪些網站安裝了 Foo_Bar 版本 X 的外掛程式
隱私
註冊外掛程式是完全由剛啟用它的用戶決定的。Plugin_Register 不會自動在沒有用戶手動點擊鏈接的情況下向你的網站發送任何數據。一些文字會顯示,邀請用戶註冊外掛程式,默認的文本說明如下:
"請考慮註冊你使用的 [你的外掛程式名稱] 來告訴 [你的名字](外掛程式製作者)你正在使用它。這樣只會發送你的網站名稱和 URL 給 [你的名字],因此他們知道他們的外掛程式正在何處使用。沒有其他數據被發送。"
你可以根據每個外掛程式覆蓋此默認文本。
外掛標籤
開發者團隊
原文外掛簡介
If you are a WordPress plugin developer the chances are your plugins are available for download from the WordPress plugin repository. As part of that service the nice guys at WordPress show you how many downloads of your plugin you get per day. Very useful, and if you’re like me you check your downloads numbers very often.
However what these stats don’t show you is where your plugin is in use – which sites it is actually being activated on. Seeing that information would allow you to see exactly which sites are using your plugin, when they installed it, and what version the site is running. That is exactly what Plugin Register does.
By including the Plugin_Register class and calling it with some simple code in your plugin, your plugin will prompt the user to register your plugin when they activate it. When they register the plugin, the Plugin Register database on your site will be updated with the name and version of your plugin, and the site name and URL where that plugin has just been activated. A simple call is made to your website to save these details in the Plugin Register table, and you get some great statistics on which site is installing what versions of your plugins.
So, what do you need to put in your plugin? This example code hows you everything you need:
`// include the Plugin_Register class
require_once( “plugin-register.class.php” );
// create a new instance of the Plugin_Register class
$register = new Plugin_Register(); // leave this as it is
$register->file = FILE; // leave this as it is
$register->slug = “pluginregister”; // create a unique slug for your plugin (normally the plugin name in lowercase, with no spaces or special characters works fine)
$register->name = “Plugin Register”; // the full name of your plugin (this will be displayed in your statistics)
$register->version = “1.0”; // the version of your plugin (this will be displayed in your statistics)
$register->developer = “Chris Taylor”; // your name
$register->homepage = “http://www.stillbreathing.co.uk”; // your WordPress website where Plugin Register is installed (no trailing slash)
$register->Plugin_Register(); // set Plugin Register to be called when the plugin is activated
The reports you get include:
Graphs showing how many registrations have been made for the last 24 hours, 14 days, 12 weeks and 12 months
A list of all plugins registered, with how many unique versions and unique sites
A list of all versions of a particular plugin, with the number of unique sites
A list of all sites which have registered any of your plugins
Details of what plugins were registered on a particular day
A search, so you can see what sites have got version X of plugin Foo_Bar installed
Privacy
Registering a plugin is completely up to the user who has just activated it. Plugin Register does NOT automatically send any data back to your website without the user manually clicking a link. Some text is displayed which invites the user to register the plugin, by default it says:
“Please consider registering your use of [your plugin name] to tell [your name] (the plugin maker) you are using it. This sends only your site name and URL to [your name] so they know where their plugin is being used. No other data is sent.”
It is possible to override this default text on a per-plugin basis.
