Sample WordPress plugin that demonstrates how a plugin can connect to a pmpro-plugin-licensing store for license activation and automatic updates.
This repo is intentionally small. It exists to show the moving pieces you need in a client plugin:
- plugin constants for version, file hash, and store URL
- an updater class that talks to the store's REST API
- an activator class that activates, deactivates, and checks license status
- a basic admin UI for entering a license key
If you copy this sample into a real plugin, rename the plugin-specific pieces:
- constants such as
PMPRO_PL_SAMPLE_PLUGIN_VERSION,PMPRO_PL_SAMPLE_PLUGIN_HASH, andPMPRO_PL_SAMPLE_PLUGIN_STORE_URL - the main plugin class
PMPRO_PL_Sample_Plugin - the updater and activator classes
PMPRO_PL_Sample_UpdaterandPMPRO_PL_Sample_Activator - the option name
pmpro_pl_sample_plugin_license_key - the transient key
pmpro_pl_sample_plugin_update_response - the text domain
pmpro-pl-sample-plugin
The bundled base classes handle most of the shared license/update behavior. Your plugin-specific classes mainly provide the constants and names that make the integration unique to your plugin.
The Paid Memberships Pro store must be running (pmpro-plugin-licensing)[https://github.com/breakfastco/pmpro-plugin-licensing].
The sample stores its license key in a WordPress option:
wp option get pmpro_pl_sample_plugin_license_key
Users manage it on:
options-general.php?page=pmpro_pl_sample_plugin
WordPress caches update metadata in a transient:
wp transient get pmpro_pl_sample_plugin_update_response
Delete it to force the sample plugin to fetch fresh metadata from the store:
wp transient delete pmpro_pl_sample_plugin_update_response