Skip to main content

Integrating WordPress Products for Multisites Networks

The Freemius WordPress SDK is fully compatible with WordPress Multisite Network and can be integrated into plugins and themes that are designed to work in a multisite environment.

This guide will walk you through the necessary steps to achieve a successful integration.

The integration process is the same as for a single site, but there are a few additional considerations to keep in mind when integrating the SDK into a multisite network.

  1. You must check the appropriate option in the SDK integration form to ensure that the SDK is properly configured for multisite use.

  2. It is important to ensure that the SDK is properly initialized for each site on the network. This can be done by using the is_multisite() function to check if the plugin or theme is being used on a Multisite Network, and then initializing the SDK accordingly.

    if ( is_multisite() ) {
    // Initialize the SDK for multisite network.
    if ( ! function_exists( 'ap_fs' ) ) {
    // Create a helper function for easy SDK access.
    function ap_fs() {
    global $ap_fs;

    if ( ! isset( $ap_fs ) ) {
    // Activate multisite network integration.
    if ( ! defined( 'WP_FS__PRODUCT_{PRODUCT_ID}_MULTISITE' ) ) {
    define( 'WP_FS__PRODUCT_{PRODUCT_ID}_MULTISITE', true );
    }

    // Include Freemius SDK.
    require_once dirname( __FILE__ ) . '/vendor/freemius/start.php';

    // Your SDK configuration options here.
    $ap_fs = fs_dynamic_init(array(
    'id' => 12345,
    'slug' => 'my-plugin',
    'type' => 'plugin',
    'public_key' => 'pk_n56hrjss36joj632vgyy345ggv555',
    'menu' => array(
    'pricing' =>true,
    'contact' => true,
    'support' => true,
    'addons' => true,
    'account' => true,
    ),
    'is_org_compliant' => true,
    ));
    }

    return $ap_fs;
    }
    }
    }
  3. Once the SDK is initialized, you can proceed to wrap your premium code with license handling methods like in the single plugins. See the SDK integration guide for more details on how to do this.