Initializing the SDK
This is the single most important page — and the one where a wrong assumption causes real, hard-to-debug failures. Read it carefully.
The entry point is Sdk::bootstrap() — there is no Appneck::init()
If you’ve seen Appneck::init() anywhere, that is wrong and will cause
a fatal “class not found” error. The real entry point is:
\Appneck\Sdk\Sdk::bootstrap( ... )It returns an object (a Plugin instance). You keep that object and
call day-to-day methods (like tracking events) on it — the SDK is not a
pile of static calls.
The full initialization call
Place this at the top level of your main plugin file (see the warning
on the previous page about why it must not go inside plugins_loaded):
require_once __DIR__ . '/vendor/appneck/wordpress-sdk/appneck-sdk.php';
appneck_sdk_load_latest();
$GLOBALS['acme_sdk'] = \Appneck\Sdk\Sdk::bootstrap(
'pk_your_product_key', // your API/product key
'sk_your_product_secret', // your product secret
'https://appneck.com', // the Appneck server URL — see below
__FILE__ // your main plugin file (so the SDK can hook activation/deactivation)
);Why store it in $GLOBALS (or another variable you keep)?
bootstrap() hands back the Plugin object. You need to hold onto it so
you can call methods like ->track() later from elsewhere in your plugin.
Storing it in a global (or your own plugin’s singleton/container) is the
simplest way. If you throw the return value away, you lose your handle to
the SDK.
The three arguments you must supply
| Argument | What it is |
|---|---|
API/product key (pk_...) | Identifies your Product. Get it from your Appneck Organization Panel. |
Product secret (sk_...) | Used to sign requests securely. Treat like a password. |
| Base URL | Where the SDK sends requests — see the dedicated section below. |
Plugin file (__FILE__) | Lets the SDK register activation/deactivation hooks against your plugin. |
Options (the last argument, optional)
| Option | What it does |
|---|---|
is_premium | true for a pro build you sell yourself: no consent prompt, always on. Default false (free): nothing is sent until the site owner clicks Allow & Continue. See Handling User Consent. |
icon_url | Your product icon, shown in the free opt-in card. |
\Appneck\Sdk\Sdk::bootstrap( 'pk_...', 'sk_...', 'https://appneck.com', __FILE__,
null, null, null, null,
array( 'is_premium' => true, 'icon_url' => plugins_url( 'assets/icon-128.png', __FILE__ ) )
);The server URL — you MUST pass it, there is no default
This is a common point of confusion, so it’s spelled out plainly:
-
The SDK has no hardcoded default URL, no constant, no environment variable fallback. If you don’t pass a valid
https://...URL, the SDK fails validation — it won’t silently “figure out” where Appneck is. -
For production, the URL is:
https://appneck.com -
For local testing, pass your local backend URL instead — this is how you point the SDK at a dev server without touching anything else:
\Appneck\Sdk\Sdk::bootstrap( 'pk_test_...', 'sk_test_...', 'http://localhost:8080', // your local Appneck backend __FILE__ );
Security note: the base URL belongs in your plugin’s code, set by you the developer — never expose it as a setting the site’s end-user can change. Letting an end-user redirect telemetry to an arbitrary server is a data-redirection risk.
What happens automatically after bootstrap()
Once bootstrapped, the SDK auto-wires these — you don’t call anything:
- Installation registration (first run enrolls the site — for a free plugin, only after the site owner clicks Allow & Continue)
- Activation / deactivation lifecycle hooks
- The heartbeat cron (periodic “still alive” signal)
- The consent prompt flow
- The deactivation (uninstall) survey
You only make explicit calls for: custom events, the “change your mind”
consent control, announcements rendering, and the separate
uninstall.php file (all covered in the following pages).
Free plugins: don’t skip the “change your mind” control. The SDK never places it by itself, so without
$sdk->consent_notice()->render_settings_section()on your settings page a user who opted in has no way to opt out. See Handling User Consent.
One thing bootstrap does NOT handle: uninstall
Deleting a plugin is special in WordPress. The heartbeat/deactivation flow
is automatic, but true uninstall cleanup requires a separate file — see
Testing Your Integration and the note below.
You must create an uninstall.php at your plugin’s root and call
Sdk::uninstall(...) there. This is covered where it’s needed; just know
now that bootstrap() alone does not cover uninstall.
Next: Required Disclosure →