[WordPress] 外掛分享: {eac}SoftwareRegistry Distribution SDK

WordPress 外掛 {eac}SoftwareRegistry Distribution SDK 的封面圖片。

前言介紹

  • 這款 WordPress 外掛「{eac}SoftwareRegistry Distribution SDK」是 2022-07-13 上架。
  • 目前尚無安裝啟用數,是個很新的外掛。如有要安裝使用,建議多測試確保功能沒問題!
  • 上一次更新是 2024-11-23,距離現在已有 161 天。
  • 外掛最低要求 WordPress 5.8 以上版本才可以安裝。
  • 外掛要求網站主機運作至少需要 PHP 版本 7.4 以上。
  • 尚未有人給過這款外掛評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

kevinburkholder |

外掛標籤

license manager | registration API | software license | software registry | software registration |

內容簡介

{eac} SoftwareRegistry Distribution SDK 是一個擴展外掛程式,可以加入到 {eac} SoftwareRegistry Software Registration Server。

軟體註冊中心發布 SDK,用於生成自定義的 PHP 套件,以便在您的軟體項目中註冊您的產品,並管理該註冊。

所生成的 SDK 套件中包含了自訂版本的 "readme.txt" 檔案。

SDK 提供了您實現應用程序程式介面與軟體註冊中心所需的大部分 PHP 程式碼。

軟體註冊 SDK 套件包括:

(your_productid)_registration.(wordpress_or_filebased).trait.php
(your_productid)_registration.includes.php
(your_productid)_registration.interface.php
(your_productid)_registration.interface.trait.php
(your_productid)_registration.refresh.php

軟體註冊中心實作

從 (your_productid)_registration.zip 檔案中解壓縮後,將 (your_productid)_registration 資料夾移到您的專案中。

在您的專案或類別檔案中,包含 ‘(your_productid)_registration/(your_productid)_registration.includes.php’ 程式檔案,以載入必需的介面和特性。

然後,您的類別檔案必須:

實作 \(your_namespace)\Interfaces\(your_productid)_registration
使用 \(your_namespace)\Traits\(your_productid)_registration_(wordpress_or_filebased)

例如:

include "(your_productid)_registration/(your_productid)_registration.includes.php";

class implements \(your_namespace)\Interfaces\(your_productid)_registration
{
use \(your_namespace)\Traits\(your_productid)_registration_(wordpress_or_filebased);
...
}

(your_productid)_registration.interface.php 檔案將包含您的產品和註冊伺服器 API 常數。

const SOFTWARE_REGISTRY_PRODUCTID = '{your_software_registry_productid}';
const SOFTWARE_REGISTRY_HOST_URL = '{your_software_registry_host_url}';
const SOFTWARE_REGISTRY_CREATE_KEY = '{your_software_registry_create_key}';
const SOFTWARE_REGISTRY_UPDATE_KEY = '{your_software_registry_update_key}';
const SOFTWARE_REGISTRY_READ_KEY = '{your_software_registry_read_key}';

使用 API

API 參數

API 參數將作為一個陣列傳遞:

$apiParams =
[
'registry_key' => '唯一識別 ID', // * 註冊金鑰 (由註冊中心分配)
'registry_name' => 'Firstname Lastname', // 註冊人全名
'registry_email' => '[email protected]', // * 註冊人電子郵件
'registry_company' => 'Comapny/Organization Name', // 註冊人公司名稱
'registry_address' => 'Street\n City St Zip', // 註冊人完整地址 (textarea)
'registry_phone' => 'nnnnnnnnnn', // 註冊人電話
'registry_product' => 'productId', // * 您的產品名稱/ID ((your_productid))
'registry_title' => 'Product Title', // 您的產品標題
'registry_description' => 'Product Description', // 您的產品描述
'registry_version' => 'M.m.p', // 您的產品版本
'registry_license' => 'Lx', // * 您的產品授權
];

原文外掛簡介

{eac}SoftwareRegistry Distribution SDK is an extension plugin to {eac}SoftwareRegistry Software Registration Server.
The Software Registry Distribution SDK is used to generate a custom PHP package that you can include in your software project to register your product with your registration server and manage that registration.
A custom version of this “readme.txt” file is included in the generated SDK package.
The SDK provides most of the PHP code you will need to implement the Application Program Interface with your Software Registration Server.
Included with the Software Registration SDK package…

(your_productid)_registration.(wordpress_or_filebased).trait.php
(your_productid)_registration.includes.php
(your_productid)_registration.interface.php
(your_productid)_registration.interface.trait.php
(your_productid)_registration.refresh.php

Software Registry Implementation
After extracting the (your_productid)_registration.zip file, move the (your_productid)_registration folder to your project.
In your project or class file, include (your_productid)_registration/(your_productid)_registration.includes.php to load the required interface and traits.
Your class file must then:

implement \(your_namespace)\Interfaces\(your_productid)_registration
use \(your_namespace)\Traits\(your_productid)_registration_(wordpress_or_filebased)

Example:
include "(your_productid)_registration/(your_productid)_registration.includes.php";

class implements \(your_namespace)\Interfaces\(your_productid)_registration
{
use \(your_namespace)\Traits\(your_productid)_registration_(wordpress_or_filebased);
...
}

(your_productid)_registration.interface.php will have your product and registration server API constants.
const SOFTWARE_REGISTRY_PRODUCTID = '{your_software_registry_productid}';
const SOFTWARE_REGISTRY_HOST_URL = '{your_software_registry_host_url}';
const SOFTWARE_REGISTRY_CREATE_KEY = '{your_software_registry_create_key}';
const SOFTWARE_REGISTRY_UPDATE_KEY = '{your_software_registry_update_key}';
const SOFTWARE_REGISTRY_READ_KEY = '{your_software_registry_read_key}';

Using The API
API Parameters
API parameters are passed as an array:
$apiParams =
[
'registry_key' => 'unique ID', // * registration key (assigned by registry server)
'registry_name' => 'Firstname Lastname', // registrant's full name
'registry_email' => '[email protected]', // * registrant's email address
'registry_company' => 'Comapny/Organization Name', // registrant's company name
'registry_address' => 'Street\n City St Zip', // registrant's full address (textarea)
'registry_phone' => 'nnnnnnnnnn', // registrant's phone
'registry_product' => 'productId', // * your product name/id ((your_productid))
'registry_title' => 'Product Title', // your product title
'registry_description' => 'Product Description', // your product description
'registry_version' => 'M.m.p', // your product version
'registry_license' => 'Lx', // 'L1'(Lite), 'L2'(Basic), 'L3'(Standard), 'L4'(Professional), 'L5'(Enterprise), 'LD'(Developer), 'LU'(Unlimited)
'registry_count' => int, // Number of licenses (users/seats/devices)
'registry_variations' => array('name'=>'value',...), // array of name/value pairs
'registry_options' => array('value',...), // array of registry options
'registry_domains' => array('domain',...), // array of valid/registered domains
'registry_sites' => array('url',...), // array of valid/registered sites/uris
'registry_transid' => '', // external transaction id
'registry_timezone' => '', // standard timezone string (client timezone)
];

* Required values (registry_key not required when creating a new registration).

If setting registry_transid, the recommended (not required) format is {id}|{source}|{suffix} where {id} is the transaction id, {source} indicates the source of the transaction, and {suffix} may be used as needed.

Any additional fields passed wil be saved as custom fields.
Although typically set by the Software Registry server, with the proper option setting, the API may override:
[
'registry_status' => 'status', // 'pending', 'trial', 'active', 'inactive', 'expired', 'terminated'
'registry_effective' => 'YYYY-MM-DD', // Effective date (Y-m-d)
'registry_expires' => 'YYYY-MM-DD', // Expiration date (Y-m-d) or term ('30 days', '1 year',... added to effective date)
];

Payment information may be posted with:
[
'registry_paydue' => float, // amount to be paid/billed,
'registry_payamount' => float, // amount paid,
'registry_paydate' => 'YYYY-MM-DD', // date paid
'registry_payid' => 'payment id' // transaction id/check #, etc.
'registry_nextpay' => 'YYYY-MM-DD', // next payment/renewal date
];

API Requests
Create/request a new registration…
$response = $this->registryApiRequest('create',$apiParams);

Activate an existing registration…
$response = $this->registryApiRequest('activate',['registry_key' => '']);

Activate and Update an existing registration…
$response = $this->registryApiRequest('activate',$apiParams);

Deactivate an existing registration…
$response = $this->registryApiRequest('deactivate',['registry_key' => '']);

Verify or Refresh an existing registration…
$response = $this->registryApiRequest('verify',['registry_key' => '']);
$response = $this->registryApiRequest('refresh',$apiParams);

Revise an existing registration…
$response = $this->registryApiRequest('revise',$apiParams);

API Response
The API response is a standard object. status->code is an http status, 200 indicating success.
status ->
(
'code' -> 200, // HTTP status code
'message' -> '(action) ok' // (action) = 'create', 'activate', 'deactivate', 'verify', 'revise'
),
registration ->
(
'registry_key' -> string // UUID,
'registry_status' -> string, // 'pending', 'trial', 'active', 'inactive', 'expired', 'terminated', 'invalid'
'registry_effective' -> string, // DD-MMM-YYYY effective date
'registry_expires' -> string, // DD-MMM-YYYY expiration date
'registry_name' -> string,
'registry_email' -> string,
'registry_company' -> string,
'registry_address' -> string,
'registry_phone' -> string,
'registry_product' -> string,
'registry_title' -> string,
'registry_description' -> string,
'registry_version' -> string,
'registry_license' -> string,
'registry_count' -> int,
'registry_variations' -> array,
'registry_options' -> array,
'registry_domains' -> array,
'registry_sites' -> array,
'registry_transid' -> string,
'registry_timezone' -> string,
'registry_valid' -> bool, // true/false
),
registrar ->
(
'contact' -> object(
'name' -> string // Registrar Name
'email' -> string // Registrar Support Email
'phone' -> string // Registrar Telephone
'web' -> string // Registrar Web Address
),
'cacheTime' -> int, // in seconds, time to cache the registration response (Default Cache Time)
'refreshInterval' -> int, // in seconds, time before refreshing the registration (Default Refresh Time)
'refreshSchedule' -> string, // 'hourly','twicedaily','daily','weekly' corresponding to refreshInterval
'options' -> array( // from settings page, registrar_options (Allow API to...)
'allow_set_key',
'allow_set_status',
'allow_set_effective',
'allow_set_expiration',
'allow_activation_update'
),
'notices' -> object(
'info' -> string, // information message text
'warning' -> string, // warning message text
'error' -> string, // error message text
'success' -> string, // success message text
),
'message' -> string, // html message
),
registryHtml -> string, // html (table) of human-readable registration values
supplemental -> mixed, // supplemental data/html assigned via filters (developer's discretion).

On a successful response (status->code = 200), the SDK will automatically cache the registration data and schedule the next refresh event (you do not have to do this).
notices may be set (according to severity) to indicate an expiration or pending expiration and should be displayed to the user. Typically, only one notice will be set but they can be set via the eacSoftwareRegistry_api_registration_notices filter.
message is set via the eacSoftwareRegistry_api_registration_message filter.
supplemental is set via the eacSoftwareRegistry_api_registration_supplemental filter.
On an error response, an additional element is included:
error ->
(
'code' -> 'error_code',
'message' -> 'error message'
),

error->message may be more informative than status->message.
Errors may be handled with something like:
if ($this->is_api_error($response))
{
echo "

Error ".$response->error->code." : ".$response->error->message."

";
}

Methods, Hooks, and Callbacks
Useful methods built into the SDK…
$this->isValidRegistration();
// Returns boolean
if ( $this->isValidRegistration() ) {...}

$this->getRegistrationKey();
// Returns the current registration key
$registrationKey = $this->getRegistrationKey();

$this->getCurrentRegistration();
// Returns the current registration object (above response object)
$currentRegistration = $this->getCurrentRegistration();

$this->isRegistryValue($keyName);
// Returns the value of a specific registry key
$regStatus = $this->isRegistryValue( 'status ');

$this->isRegistryValue($keyName, $value, $test);
// Returns boolean comparison of the value of a registry key ($test is '=|eq' (default), '|gt', '=|ge')
if ( $this->isRegistryValue('license', 'L3', '>=') ) {...}

Several hooks are available to customize or react to registration events.
In WordPresss, there are several actions and filters, for file based projects there are corresponding callback methods…
filter/callback: (your_productid)_api_remote_request( $request, $endpoint )
@param array $request ['method'=>, 'timeout'=>, 'redirection'=>, 'sslverify'=>, 'headers'=>, 'body'=>]
@param string $endpoint create, activate, deactivate, verify, refresh, revise
@return array request body

action/callback: (your_productid)_api_remote_response( $body, $request, $endpoint )
@param array $body response body
@param array $request ['method'=>, 'timeout'=>, 'redirection'=>, 'sslverify'=>, 'headers'=>, 'body'=>]
@param string $endpoint create, activate, deactivate, verify, refresh, revise

action/callback: (your_productid)_api_remote_$endpoint( $body, $request, $endpoint )
@param array $body response body
@param array $request ['method'=>, 'timeout'=>, 'redirection'=>, 'sslverify'=>, 'headers'=>, 'body'=>]
@param string $endpoint create, activate, deactivate, verify, refresh, revise

action/callback: (your_productid)_api_remote_error( $error, $request, $endpoint )
@param object $error {status:{}, error: {}}
@param array $request ['method'=>, 'timeout'=>, 'redirection'=>, 'sslverify'=>, 'headers'=>, 'body'=>]
@param string $endpoint create, activate, deactivate, verify, refresh, revise

action/callback: (your_productid)_update_registration($registration)
@param array $registration registration object

action/callback: (your_productid)_purge_registration()

What You Need To Do
For WordPress Projects
In your class constructor/initialization, add an action to fulfill the registration refresh scheduled by the scheduleRegistryRefresh() method in (your_productid).wordpress.trait.php
\add_action( '(your_productid)_registry_refresh', array($this, 'refreshRegistration') );

You can add this and other hooks with:
$this->addSoftwareRegistryHooks();

The addSoftwareRegistryHooks() method adds:
\add_action( '(your_productid)_registry_refresh', array($this, 'refreshRegistration') );
\add_filter( '(your_productid)_is_registered', array($this, 'isValidRegistration') );
\add_filter( '(your_productid)_registration_key', array($this, 'getRegistrationKey') );
\add_filter( '(your_productid)_registration', array($this, 'getCurrentRegistration') );
\add_filter( '(your_productid)_registry_value', array($this, 'isRegistryValue'), 10, 4 );

Example:
include "(your_productid)_registration/(your_productid)_registration.includes.php";

class implements \(your_namespace)\Interfaces\(your_productid)_registration
{
use \(your_namespace)\Traits\(your_productid)_registration_wordpress;
...
public function __construct()
{
$this->addSoftwareRegistryHooks();
}
}

For Other File Based Projects
The scheduleRegistryRefresh() method in (your_productid)_registration.filebased.trait.php is called to schedule the next registration refresh. This method can be modified to schedule a cron event to execute the refresh at a future time. The scheduled event may run (your_productid)_registration.refresh.php from the command line to refresh the registration.
When left as is, the checkRegistryRefreshEvent() method uses the key file to check for a needed registration refresh.
In your class constructor or destructor add:
$this->checkRegistryRefreshEvent();

to trigger the refresh check.
Example:
include "(your_productid)_registration/(your_productid)_registration.includes.php";

class implements \(your_namespace)\Interfaces\(your_productid)_registration
{
use \(your_namespace)\Traits\(your_productid)_registration_filebased;
...
public function __destruct()
{
/* if necessary, set HOME and/or TMP/TMPDIR/TEMP directories */
// putenv('HOME={your home directory}'); // where the registration key is stored, otherwise use $_SERVER['DOCUMENT_ROOT']
// putenv('TMP={your temp directory}'); // where the registration data is stored, otherwise use sys_get_temp_dir()
$this->checkRegistryRefreshEvent();
}
}

User Interface
Of course, the user interface is up to you, the developer, but you may look at (and maybe use) the registration UI trait included with {eac}Doojigger and used by {eac}SoftwareRegistry as an example.
see:

…/Traits/swRegistrationUI.trait.php in the eacDoojigger folder.
…/Extensions/class.eacSoftwareRegistry_registration.extension.php in the eacSoftwareRegistry folder.

See Also

{eac}SoftwareRegistry – Software Registration Server

{eac}SoftwareRegistry Custom Hooks

Copyright
Copyright © 2019-2024, EarthAsylum Consulting, distributed under the terms of the GNU GPL.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should receive a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「{eac}SoftwareRegistry Distribution SDK」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


1.0.1 | 1.0.2 | 1.0.3 | 1.0.4 | 1.0.5 | 1.0.6 | 1.0.7 | 1.0.8 | 1.0.9 | 1.1.0 | 1.1.1 | trunk |

延伸相關外掛(你可能也想知道)

文章
Filter
Apply Filters
Mastodon