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 & 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/):
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 & themes that are already utilizing the power of Freemius here:
* https://profiles.wordpress.org/freemius/#content-plugins
* https://includewp.com/freemius/#focus
## Code Documentation
You can find the SDK's documentation here:
https://freemius.com/help/documentation/wordpress-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):
```php
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
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):
```php
get_upgrade_url(); ?>
```
Or when calling Freemius multiple times in a scope, it's recommended to use it with the global variable:
```php
get_account_url();
?>
```
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
Add marketing content to encourage your users to upgrade for your paid version:
```php
is_not_paying() ) {
echo '' . esc_html__('Awesome Premium Features', 'my-plugin-slug') . '
';
echo '' .
esc_html__('Upgrade Now!', 'my-plugin-slug') .
'';
echo '