Installing the SDK
The Appneck WordPress SDK is a PHP package you add to your plugin. It handles the technical work — talking to Appneck’s servers, signing requests securely, batching events, and managing the plugin lifecycle (activation, deactivation, heartbeats) — so you don’t build any of that yourself.
Requirements
- PHP 7.2 or higher. Note: the SDK does not enforce this at runtime — there’s no version check that stops it loading on older PHP. It’s on you to make sure your plugin’s own minimum PHP requirement is 7.2+.
- WordPress with a standard plugin structure (a main plugin file with a header).
Getting the SDK into your plugin
Three ways in, from the least tooling to the most. All three must end with the
SDK at your-plugin/vendor/appneck/wordpress-sdk/ — that is the exact path
every require_once on this page and the next one uses.
Download the zip (no tooling needed)
Download appneck-wordpress-sdk.zip
GitHub names the extracted folder after the branch, so it unpacks as
appneck-wordpress-sdk-main — which is not the folder name you require
below. Rename it as you move it into place:
unzip appneck-wordpress-sdk-main.zip
mkdir -p your-plugin/vendor/appneck
mv appneck-wordpress-sdk-main your-plugin/vendor/appneck/wordpress-sdk⚠️ Don’t skip the rename. Leave the
-mainsuffix on and therequire_oncebelow points at a file that isn’t there — WordPress throws a fatal “failed to open stream” the moment someone activates your plugin, with nothing to suggest the folder name is what’s wrong.
Git clone
git clone https://github.com/magepeopleteam/appneck-wordpress-sdk.git \
your-plugin/vendor/appneck/wordpress-sdkComposer
The package is not published on Packagist, so a plain
composer require appneck/wordpress-sdk fails with “Could not find a matching
version of package appneck/wordpress-sdk”. Point Composer at the repository
itself instead, in your plugin’s composer.json:
{
"repositories": [
{ "type": "vcs", "url": "https://github.com/magepeopleteam/appneck-wordpress-sdk" }
],
"require": { "appneck/wordpress-sdk": "dev-main" }
}composer update appneck/wordpress-sdkComposer installs it to vendor/appneck/wordpress-sdk/ — the same path as the
other two methods, and no rename needed.
Whichever route you took, you then load it. The SDK ships two files that matter at load time:
appneck-sdk.php— a lightweight version registry only. It defines no classes. Its job is to let multiple plugins on the same site safely each ship their own copy of the SDK, and agree on which (newest) copy actually loads. This is the “loader race” the SDK solves for you.bootstrap.php— where the real classes actually load from.
The loading pattern (important — don’t skip a step)
At the very top of your plugin’s main file:
// 1. Require the SDK loader
require_once __DIR__ . '/vendor/appneck/wordpress-sdk/appneck-sdk.php';
// 2. Explicitly tell the loader to pick and load the latest registered copy
appneck_sdk_load_latest();Why the explicit
appneck_sdk_load_latest()call? Because more than one of your plugins (or someone else’s) might bundle the Appneck SDK on the same site. The registry step lets them all register their version first; this call then loads whichever is newest. You must call it yourself — it does not run automatically.
Where initialization goes (read this before the next page)
Once loaded, you initialize the SDK by calling Sdk::bootstrap(...). There
is one rule that trips people up, so it’s stated here up front:
⚠️
bootstrap()must run at the top level of your main plugin file — NOT inside aplugins_loadedhook (or any other hook).If you defer it into
plugins_loaded, WordPress will have already decided about activation/deactivation before your code runs, so the SDK can’t register its activation hook, can’t create its event table, and can’t schedule its heartbeat cron. It fails silently — no error, just no data. Keepbootstrap()at the top level.
The full initialization call is covered on the next page.
Next: Initializing the SDK →