Skip to main content

SDK Integration

Time to complete: ~5 minutes
Prerequisites: Completed Project Setup

Now that we have our plugin's foundation set up, let's integrate the PaidCommunities PHP SDK and configure our plugin's structure.

Initializing the SDK​

First, let's update our main plugin file to initialize the PaidCommunities SDK:

awesome-seo.php
<?php
/**
* Plugin Name: Awesome SEO
* Plugin URI: https://awesome-seo.com
* Description: SEO plugin that will increase site ranking
* Version: 1.0.0
* Author: PaidCommunities support@paidcommunities.com
* Author URI: https://awesome-seo.com/about-us
* Text Domain: awesome-seo
* Domain Path: /i18n/languages/
* Tested up to: 6.6
* Update URI: https://paidcommunities.com
*/

require __DIR__ . '/vendor/autoload.php';

$plugin = new \PaidCommunities\WordPress\PluginConfig(
__FILE__,
'prd_80y2N3N2L11O2ee1'
);
note

The PluginConfig constructor requires two parameters:

  • Plugin absolute file path (e.g., /wp-content/plugins/awesome-seo/awesome-seo.php)
  • The ID of the product that this plugin represents These are used to manage updates and licensing.

Setting Up Plugin Structure​

Let's create a proper directory structure for our plugin's classes:

command line
mkdir src

Now we'll configure Composer to autoload our plugin's classes. Update your composer.json:

composer.json
{
"name": "paidcommunities/awesome-seo",
"description": "Awesome SEO plugin",
"type": "project",
"authors": [
{
"name": "PaidCommunities"
}
],
"require": {
"paidcommunities/wordpress-sdk": "^0.0.1"
},
"autoload": {
"psr-4": {
"AwesomeSEO\\": "src/"
}
}
}

After updating the composer.json, regenerate the autoloader:

command line
composer dumpautoload

Next Steps​

At this point, you have:

  • Initialized the PaidCommunities SDK
  • Set up your plugin's directory structure
  • Configured PSR-4 autoloading for your plugin's classes

In the next section, we'll create an admin page for license activation and begin implementing the licensing features.