-
-
Notifications
You must be signed in to change notification settings - Fork 1
Developers Guide
- Clone repository
$ git clone https://github.com/Labs64/PluginPass.git
- Start environment
$ docker-compose up -d
- Build project
$ docker exec --workdir=/var/www/html/wp-content/plugins/pluginpass pluginpass-wordpress ./dockerfiles/bin/prj-build.sh
Now you can browse the site at http://localhost:8000 (user/pass: pluginpass/pluginpass)
- Stop environment
$ docker-compose down
The easiest way to test PluginPass is to:
- Create a new PluginPass Demo plugin using https://wppb.me
- Plugin Name:
PluginPass Demo
- Plugin Slug:
pluginpass-demo
-
Extract downloaded ZIP file into
data/pluginpass-demo
folder (Docker enabled) -
Copy examples/class-pluginpass-demo-settings.php into
data/pluginpass-demo/admin
and adjust$api_key
,$product_number
and$product_module_number
according to the product configuration made in Set up NetLicensing. -
Register PluginPass Demo settings page:
data/pluginpass-demo/admin/class-pluginpass-demo-admin.php
public function __construct( $plugin_name, $version ) {
$this->plugin_name = $plugin_name;
$this->version = $version;
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-pluginpass-demo-settings.php';
}
data/pluginpass-demo/includes/class-pluginpass-demo.php
private function define_admin_hooks() {
$plugin_admin = new Pluginpass_Demo_Admin( $this->get_plugin_name(), $this->get_version() );
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
$plugin_settings = new Pluginpass_Demo_Settings( $this->get_plugin_name(), $this->get_version() );
$this->loader->add_action( 'admin_menu', $plugin_settings, 'pluginpass_demo_options_menu' );
$this->loader->add_action( 'admin_init', $plugin_settings, 'pluginpass_demo_options_page' );
}
PluginPass Demo plugin should be visible now in your local WordPress instance.
After plugin activation a new admin menu item will be accessible: Settings->PluginPass Demo
.
Use the following code snippet as a starting point for your tests or PluginPass integration:
if (!is_plugin_active('pluginpass/pluginpass.php') and current_user_can('activate_plugins')) {
// Stop activation redirect and show error
wp_die('This plugin/theme requires PluginPass plugin to be installed and active!');
}
$api_key = '588a16b3-d8b8-4a37-8965-b217eb93dc70';
$product_number = 'P6N6UW7U4';
$product_module_number = 'MN5VYRR54';
$plugin_folder = 'pluginpass-demo/pluginpass-demo.php';
$quard = new \PluginPass\Inc\Common\PluginPass_Guard( $api_key, $product_number, $plugin_folder );
$quard->set_consent();
if ($quard->validate($product_module_number)) {
echo "<div class=\"notice notice-success\"><p>Valid license(-s) for $product_module_number found.</p></div>";
} else {
$go_to_shop = $quard->get_shop_url();
echo "<div class=\"notice notice-error\"><p>No valid license(-s) for $product_module_number found!</p><p>Acquire licenses here: $go_to_shop</p></div>";
}
echo '<p>RAW Validation Result:</p><pre>';
print_r($quard->validation_result());
echo '</pre>';
Labs64 NetLicensing - Innovative License Management Solution
NetLicensing.IO | Licensing Models | Getting Started | NetLicensing API | PluginPass