Skip to content

breakfastco/pmpro-pl-sample-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pmpro-pl-sample-plugin

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

What to change in your own plugin

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, and PMPRO_PL_SAMPLE_PLUGIN_STORE_URL
  • the main plugin class PMPRO_PL_Sample_Plugin
  • the updater and activator classes PMPRO_PL_Sample_Updater and PMPRO_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.

Store plugin

The Paid Memberships Pro store must be running (pmpro-plugin-licensing)[https://github.com/breakfastco/pmpro-plugin-licensing].

Useful commands

License key storage

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

Update response cache

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

About

WordPress plugin. Sample plugin with a pmpro-plugin-licensing updater. Helps test the deliver of plugin updates.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages