|
/ Knowledge Base /Developer Docs/ Selling WordPress Plugins and Themes With SureCart

Selling WordPress Plugins and Themes With SureCart

With our SureCart Business and Pro plans, you can purchase an add-on for our software licensing platform to sell premium themes and plugins with SureCart.

What’s great about using SureCart is you offload any update checks, downloads, and any other resource-intensive tasks off your website – we handle this for you.

We’ve built a WordPress SDK to make it easy to get started.

Installing WordPress SDK

Clone the above repository in your project.

cd /path/to/your/project/folder
git clone https://github.com/surecart/wordpress-sdk.git licensing

Now include these dependencies in your plugin/theme.

if ( ! class_exists( 'SureCart\Licensing\Client' ) ) {
    require_once __DIR__ . '/licensing/src/Client.php';
}

Include a release.json File

Add a release.json file to the root of your plugin or theme project.
release.json requires the following:

PropertyDescription
nameYour plugin or theme display name.
slugYour plugin or theme slug. IMPORTANT This must match the folder name of your project.
authorHTML to be used for the author of the plugin.
author_profileA url to your author profile.
versionThe version of your plugin or theme.
requiresThe required WordPress version.
testedThe version of WordPress the plugin has been tested with.
requires_phpAn array of sections to tab through in the updated UI.
sectionsA URL to your author profile.

Sections will require a changelog property with an HTML string of your changelog.

Example release.json File
{
  "name": "SureCart Example Plugin",
  "slug": "surecart-plugin-example",
  "author": "<a href='https://surecart.com'>SureCart</a>",
  "author_profile": "https://surecart.com",
  "version": "0.9.0",
  "requires": "5.6",
  "tested": "6.1.0",
  "requires_php": "5.3",
  "sections": {
    "description": "This is my plugin description.",
    "changelog": "<h4>1.0 –  July 20, 2022</h4><ul><li>Bug fixes.</li><li>Initital release.</li></ul>",
    "frequently asked questions": "<h4>Question<h4><p>Answer</p>"
  }
}

Usage Example

Please refer to the Installation section before you start using this class.

if ( ! class_exists( 'SureCart\Licensing\Client' ) ) {
    require_once __DIR__ . '/licensing/src/Client.php';
}

// initialize client with your plugin name.
$client = new \SureCart\Licensing\Client( 'Your Plugin', __FILE__ );

// set your textdomain.
$client->set_textdomain( 'your-textdomain' );

// add the pre-built license settings page.
$client->settings()->add_page( 
    [
    'type'                 => 'submenu', // Can be: menu, options, submenu.
    'parent_slug'          => 'your-plugin-menu-slug', // add your plugin menu slug.
    'page_title'           => 'Manage License',
    'menu_title'           => 'Manage License',
    'capability'           => 'manage_options',
    'menu_slug'            => $this->client->slug . '-manage-license',
    'icon_url'             => '',
    'position'             => null,
    'parent_slug'          => '',
    'activated_redirect'   => admin_url( 'admin.php?page=my-plugin-page' ), // should you want to redirect on activation of license.
    'deactivated_redirect' => admin_url( 'admin.php?page=my-plugin-deactivation-page' ), // should you want to redirect on detactivation of license.
    ] 
);

Make sure you call this function directly, never use any action hook to call this function.

For plugins example code that needs to be used on your main plugin file.
For themes example code that needs to be used on your themes functions.php file.

More Usage

$client = new \SureCart\Licensing\Client(  'Twenty Twelve', __FILE__ );

Setting textdomain

You may set your own textdomain to translate text.

$client->set_textdomain( 'your-project-textdomain' );

We hope this article helps you. If you have any questions, please don’t hesitate to reach out to our support team. We’re here to help!

Was this doc helpful?
What went wrong?

We don't respond to the article feedback, we use it to improve our support content.

Need help? Contact Support
On this page

Download is Just A Click Away!

Enter your email address and be the first to learn about updates and new features.

E-Commerce Store Launch Checklist Download
Scroll to Top