Skip to content

WordPress Quick Start

Add license validation, auto-updates, and customer portals to your WordPress plugin.

PackEdge is modular — add only what you need.

Available Modules

ModuleDescriptionSDK
License ValidationValidate and activate licensesJS / PHP
Auto UpdatesWordPress update system integrationPHP
Release NotesDisplay changelog in pluginJS / PHP
Customer PortalLicenses, downloads, invoices, subscriptionsWP Plugin
Feedback CollectionCollect user feedbackJS / PHP
Usage AnalyticsTrack feature usageJS / PHP

SDK Installation

JS: pnpm add packedge (ES6 module, bundle with your plugin) PHP License: composer require packedge-sdk/licensePHP Analytics: composer require packedge-sdk/analytics

Setup

  1. Log into the PackEdge Console
  2. Create your product and note your public_key

License Validation

Validate license keys and manage activations.

JavaScript (ES6 Module)

bash
pnpm add packedge
javascript
// src/license.js
import packedge from 'packedge';

packedge.init('pk_your_public_key');

export async function validateLicense(licenseKey) {
  const result = await packedge.validateLicense(licenseKey);
  // site auto-detected from window.location

  if (result.valid) {
    console.log('License active until', result.license.expiresAt);
  }

  return result;
}

export async function activateLicense(licenseKey) {
  return await packedge.activateLicense(licenseKey);
}

export async function deactivateLicense(licenseKey) {
  return await packedge.deactivateLicense(licenseKey);
}

Bundle with your plugin's JS (webpack, vite, etc.) and enqueue:

php
wp_enqueue_script(
    'my-plugin-admin',
    plugin_dir_url(__FILE__) . 'dist/admin.js',
    [],
    MY_PLUGIN_VERSION,
    true
);

REST API

php
$response = wp_remote_post('https://api.packedge.dev/public/v1/licenses/validate', [
    'body' => json_encode([
        'public_key' => 'pk_your_public_key',
        'license_key' => $license_key,
        'domain' => home_url(),
    ]),
    'headers' => ['Content-Type' => 'application/json'],
]);

$body = json_decode(wp_remote_retrieve_body($response), true);

// Response:
// {
//   "valid": true,
//   "license": {
//     "key": "XXXX-XXXX-XXXX-XXXX",
//     "status": "active",
//     "expires_at": "2025-12-31T23:59:59Z"
//   },
//   "activations": { "used": 1, "limit": 3 }
// }

if ($body['valid']) {
    update_option('my_plugin_license_status', 'active');
} else {
    // Handle invalid license
    update_option('my_plugin_license_status', 'invalid');
}

Auto Updates

Enable automatic updates through WordPress admin.

bash
composer require packedge-sdk/license
php
use PackEdge\License;

// Initialize once in your main plugin file
$license = License::init('pk_your_public_key', __FILE__);

// Enable auto-updates (hooks into WordPress update system)
$license->updater();

Release Notes

Display your product's changelog within the plugin.

JavaScript

javascript
import packedge from 'packedge';

packedge.init('pk_your_public_key');

const releases = await packedge.getReleases('my-plugin');
// [
//   { version: '1.2.0', changelog: '- Added dark mode', releasedAt: '2025-01-15' },
//   { version: '1.1.0', changelog: '- New widget', releasedAt: '2025-01-01' }
// ]

PHP (REST API)

php
$response = wp_remote_get('https://api.packedge.dev/public/v1/products/my-plugin/releases');
$releases = json_decode(wp_remote_retrieve_body($response), true);

REST API

php
$response = wp_remote_get('https://api.packedge.dev/public/v1/products/my-plugin/releases');
$releases = json_decode(wp_remote_retrieve_body($response), true);

// Response:
// {
//   "data": [
//     { "version": "1.2.0", "changelog": "- Added dark mode\n- Fixed export bug", "released_at": "2025-01-15" },
//     { "version": "1.1.0", "changelog": "- New dashboard widget", "released_at": "2025-01-01" }
//   ]
// }

foreach ($releases['data'] as $release) {
    echo "<h3>{$release['version']}</h3>";
    echo "<p>{$release['changelog']}</p>";
}

Customer Portal

A complete customer self-service portal displaying licenses, downloads, invoices, subscriptions, and profile management.

Install the PackEdge Customer Portal plugin for a ready-to-use solution:

  1. Download from PackEdge Console
  2. Upload to WordPress
  3. Configure with your public_key
  4. Add [packedge_portal] shortcode to any page

The plugin provides:

  • My Licenses — View and manage active licenses
  • Downloads — Access purchased product releases
  • Invoices — View and download invoices
  • Subscriptions — Manage active subscriptions
  • Profile — Update account details

REST API (Custom Integration)

Build your own portal using the APIs. The customer ID is returned when validating a license:

php
// First, get customer ID from license validation
$license_response = wp_remote_post('https://api.packedge.dev/public/v1/licenses/validate', [
    'body' => json_encode([
        'public_key' => 'pk_your_public_key',
        'license_key' => $license_key,
        'domain' => home_url(),
    ]),
    'headers' => ['Content-Type' => 'application/json'],
]);
$license = json_decode(wp_remote_retrieve_body($license_response), true);
$customer_id = $license['license']['customer_id'];

// Then use customer ID for portal APIs (requires API key)
$headers = ['Authorization' => 'Bearer ' . $api_key];

// Get customer licenses
$licenses = wp_remote_get("https://api.packedge.dev/v1/customers/{$customer_id}/licenses", [
    'headers' => $headers,
]);

// Get customer downloads
$downloads = wp_remote_get("https://api.packedge.dev/v1/customers/{$customer_id}/downloads", [
    'headers' => $headers,
]);

// Get customer invoices
$invoices = wp_remote_get("https://api.packedge.dev/v1/customers/{$customer_id}/invoices", [
    'headers' => $headers,
]);

// Get customer subscriptions
$subscriptions = wp_remote_get("https://api.packedge.dev/v1/customers/{$customer_id}/subscriptions", [
    'headers' => $headers,
]);

// Get/update customer profile
$profile = wp_remote_get("https://api.packedge.dev/v1/customers/{$customer_id}", [
    'headers' => $headers,
]);

Feedback Collection

Collect bug reports, feature requests, and general feedback.

JavaScript

javascript
import packedge from 'packedge';

packedge.init('pk_your_public_key');

await packedge.submitFeedback({
  type: 'bug', // bug | feature | general
  message: 'Export button not working',
  email: 'user@example.com'
});

PHP

bash
composer require packedge-sdk/analytics
php
use PackEdge\Analytics;

$analytics = Analytics::init('pk_your_public_key', __FILE__);

$analytics->feedback('bug', $message, $user_email);

Usage Analytics

Track how users interact with your plugin.

JavaScript

javascript
import packedge from 'packedge';

packedge.init('pk_your_public_key');

packedge.track('feature_used', { feature: 'export' });
packedge.track('settings_changed', { setting: 'theme', value: 'dark' });

PHP

php
use PackEdge\Analytics;

$analytics = Analytics::init('pk_your_public_key', __FILE__);

$analytics->track('feature_used', ['feature' => 'export']);

Complete Example

A minimal plugin combining License Validation + Auto Updates + Analytics:

PHP (my-plugin.php):

php
<?php
/**
 * Plugin Name: My Plugin
 * Version: 1.0.0
 */

define('MY_PLUGIN_VERSION', '1.0.0');
define('MY_PLUGIN_PUBLIC_KEY', 'pk_your_public_key');

require_once plugin_dir_path(__FILE__) . 'vendor/autoload.php';

use PackEdge\License;
use PackEdge\Analytics;

// Initialize license (singleton)
$license = License::init(MY_PLUGIN_PUBLIC_KEY, __FILE__);

// Enable auto-updates
$license->updater();

// Initialize analytics
$analytics = Analytics::init(MY_PLUGIN_PUBLIC_KEY, __FILE__);

// Track activation/deactivation
register_activation_hook(__FILE__, fn() => $analytics->activated());
register_deactivation_hook(__FILE__, fn() => $analytics->deactivated('switching'));

// Check license for premium features
if ($license->is_valid()) {
    // Enable premium features
}

// Track feature usage
add_action('my_plugin_export', function() use ($analytics) {
    $analytics->track('export', ['format' => 'csv']);
});

JavaScript (src/admin.js):

javascript
import packedge from 'packedge';

packedge.init(MyPluginConfig.publicKey);

document.getElementById('validate-license')?.addEventListener('click', async () => {
    const key = document.getElementById('license-key').value;
    const result = await packedge.validateLicense(key);

    if (result.valid) {
        alert('License activated!');
    } else {
        alert('Invalid license: ' + result.error);
    }
});

Next Steps