PHPackages                             danielealessandra/wordpress-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. danielealessandra/wordpress-sdk

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

danielealessandra/wordpress-sdk
===============================

Freemius WordPress SDK

1.0.0(1y ago)020GPL-3.0-onlyPHPPHP &gt;=5.6

Since Nov 5Pushed 1y agoCompare

[ Source](https://github.com/DanieleAlessandra/wordpress-sdk)[ Packagist](https://packagist.org/packages/danielealessandra/wordpress-sdk)[ Docs](https://freemius.com)[ RSS](/packages/danielealessandra-wordpress-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (7)Versions (2)Used By (0)

Freemius WordPress SDK
======================

[](#freemius-wordpress-sdk)

Welcome to the official repository for the Freemius SDK! Adding the SDK to your WordPress plugin, theme, or add-ons, enables all the benefits that come with using the [Freemius platform](https://freemius.com) such as:

- [Software Licensing](https://freemius.com/wordpress/software-licensing/)
- [Secure Checkout](https://freemius.com/wordpress/checkout/)
- [Subscriptions](https://freemius.com/wordpress/recurring-payments-subscriptions/)
- [Automatic Updates](https://freemius.com/wordpress/automatic-software-updates/)
- [Seamless EU VAT](https://freemius.com/wordpress/collecting-eu-vat-europe/)
- [Cart Abandonment Recovery](https://freemius.com/wordpress/cart-abandonment-recovery/)
- [Affiliate Platform](https://freemius.com/wordpress/affiliate-platform/)
- [Analytics &amp; Usage Tracking](https://freemius.com/wordpress/insights/)
- [User Dashboard](https://freemius.com/wordpress/user-dashboard/)
- [Monetization](https://freemius.com/wordpress/)
- [Analytics](https://freemius.com/wordpress/insights/)
- [More...](https://freemius.com/wordpress/features-comparison/)

Freemius truly empowers developers to create prosperous subscription-based businesses.

If you're new to Freemius then we recommend taking a look at our [Getting Started](https://freemius.com/help/documentation/getting-started/) guide first.

If you're a WordPress plugin or theme developer and are interested in monetizing with Freemius then you can [sign-up for a FREE account](https://dashboard.freemius.com/register/):

Once you have your account setup and are familiar with how it all works you're ready to begin [integrating Freemius](https://freemius.com/help/documentation/wordpress-sdk/integrating-freemius-sdk/) into your WordPress product

You can see some of the existing WordPress.org plugins &amp; themes that are already utilizing the power of Freemius here:

-
-

Code Documentation
------------------

[](#code-documentation)

You can find the SDK's documentation here:

Integrating &amp; Initializing the SDK
--------------------------------------

[](#integrating--initializing-the-sdk)

As part of the integration process, you'll need to [add the latest version](https://freemius.com/help/documentation/getting-started/#add_the_latest_wordpress_sdk_into_your_product) of the Freemius SDK into your WordPress project.

Then, when you've completed the [SDK integration form](https://freemius.com/help/documentation/getting-started/#fill_out_the_sdk_integration_form) a snippet of code is generated which you'll need to copy and paste into the top of your main plugin's PHP file, right after the plugin's header comment.

Note: For themes, this will be in the root `functions.php` file instead.

A typical SDK snippet will look similar to the following (your particular snippet may differ slightly depending on your integration):

```
if ( ! function_exists( 'my_prefix_fs' ) ) {
    // Create a helper function for easy SDK access.
    function my_prefix_fs() {
        global $my_prefix_fs;

        if ( ! isset( $my_prefix_fs ) ) {
            // Include Freemius SDK.
            require_once dirname(__FILE__) . '/freemius/start.php';

            $my_prefix_fs = fs_dynamic_init( array(
                'id'                  => '1234',
                'slug'                => 'my-new-plugin',
                'premium_slug'        => 'my-new-plugin-premium',
                'type'                => 'plugin',
                'public_key'          => 'pk_bAEfta69seKymZzmf2xtqq8QXHz9y',
                'is_premium'          => true,
                // If your plugin is a serviceware, set this option to false.
                'has_premium_version' => true,
                'has_paid_plans'      => true,
                'is_org_compliant'    => true,
                'menu'                => array(
                    'slug'           => 'my-new-plugin',
                    'parent'         => array(
                        'slug' => 'options-general.php',
                    ),
                ),
                // Set the SDK to work in a sandbox mode (for development & testing).
                // IMPORTANT: MAKE SURE TO REMOVE SECRET KEY BEFORE DEPLOYMENT.
                'secret_key'          => 'sk_ubb4yN3mzqGR2x8#P7r5&@*xC$utE',
            ) );
        }

        return $my_prefix_fs;
    }

    // Init Freemius.
    my_prefix_fs();
    // Signal that SDK was initiated.
    do_action( 'my_prefix_fs_loaded' );
}
```

Usage example
-------------

[](#usage-example)

You can call anySDK methods by prefixing them with the shortcode function for your particular plugin/theme (specified when completing the SDK integration form in the Developer Dashboard):

```

```

Or when calling Freemius multiple times in a scope, it's recommended to use it with the global variable:

```

```

There are many other SDK methods available that you can use to enhance the functionality of your WordPress product. Some of the more common use-cases are covered in the [Freemius SDK Gists](https://freemius.com/help/documentation/wordpress-sdk/gists/) documentation.

Adding license based logic examples
-----------------------------------

[](#adding-license-based-logic-examples)

Add marketing content to encourage your users to upgrade for your paid version:

```
