OG LeadWheel Lite: developer's guide¶
This page lists what OG LeadWheel Lite exposes to code: actions, filters, the shortcode, the block, REST routes, MCP tools, storage and the front-end script. For settings and everyday use, see the user guide.
OG LeadWheel has no WP-CLI commands and no admin AJAX actions. The plugin folder is og-wheel, the text domain is og-wheel and PHP classes live in the OGWheel\ namespace.
Actions¶
og_wheel_subscribed¶
Fires after a successful spin when the visitor ticked the marketing consent box. Connect your mailing list here.
| Argument | Type | Meaning |
|---|---|---|
$email |
string | The address, lower case. |
$wheel |
array | The wheel's settings (see Wheel settings). |
$consent_version |
string | 12-character fingerprint of the consent wording the visitor saw. |
add_action( 'og_wheel_subscribed', function ( $email, $wheel, $consent_version ) {
my_list_add( $email, array( 'source' => 'wheel-' . $wheel['id'], 'consent' => $consent_version ) );
}, 10, 3 );
og_wheel_spun¶
Fires after every successful spin, prize or not, once the prize has been handed out.
| Argument | Type | Meaning |
|---|---|---|
$spin_id |
int | Row ID in the spin log. |
$wheel |
array | The wheel's settings. |
$segment |
array | The segment it stopped on (see Segment keys). |
$email |
string | The address, lower case. |
$coupon_code |
string | The coupon code, or empty for no prize or credits. |
add_action( 'og_wheel_spun', function ( $spin_id, $wheel, $segment, $email, $coupon_code ) {
if ( $coupon_code ) {
error_log( "Wheel {$wheel['id']} gave {$coupon_code}" );
}
}, 10, 5 );
og_wheel_saved¶
Fires after a wheel is saved from the editor in wp-admin.
| Argument | Type | Meaning |
|---|---|---|
$wheel_id |
int | The saved wheel's post ID. |
$config |
array | The cleaned settings that were stored. |
Filters¶
| Filter | Arguments | Return | When it runs |
|---|---|---|---|
og_wheel_coupon_code |
$code, $wheel, $segment |
string | Before each coupon is made. Default codes look like OGW-7KQ2M9XT. If the code already exists, the filter runs again (up to five tries). |
og_wheel_coupon_before_save |
$coupon (WC_Coupon), $wheel, $segment, $email |
WC_Coupon |
Just before the coupon is saved. Add product limits, meta and so on. |
og_wheel_award_credits |
null, $email, $amount (int), $kind (string), $wheel, $spin_id |
true, false or null |
For OG credits prizes. Return true when you handed them out, false on failure, or null to let OG Keystone do it. |
og_wheel_credits_available |
$available (bool) |
bool | Whether the OG credits prize type is offered. Default: true when OG Keystone is active. |
og_wheel_email_body |
$body (HTML), $wheel, $segment, $coupon_code |
string | Before the prize e-mail is sent. |
og_wheel_show_popup |
$show (bool), $wheel |
bool | Whether a pop-up wheel may show on this page. Basket, checkout and account pages are ruled out before this filter runs. |
og_wheel_client_ip |
$ip (string) |
string | The visitor's IP address used for the per-connection limit. Default: REMOTE_ADDR. Return a valid IP. |
og_wheel_account_endpoint |
$endpoint (string) |
string | The My Account endpoint for the Wheel prizes tab. Default wheel-prizes. |
// Coupons only for one product category.
add_filter( 'og_wheel_coupon_before_save', function ( $coupon, $wheel, $segment, $email ) {
$coupon->set_product_categories( array( 42 ) );
return $coupon;
}, 10, 4 );
// Behind a trusted proxy that sets X-Real-IP.
add_filter( 'og_wheel_client_ip', function ( $ip ) {
return isset( $_SERVER['HTTP_X_REAL_IP'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_REAL_IP'] ) ) : $ip;
} );
// Never show wheel pop-ups on blog posts.
add_filter( 'og_wheel_show_popup', function ( $show, $wheel ) {
return is_singular( 'post' ) ? false : $show;
}, 10, 2 );
Warning
Only trust a proxy header in og_wheel_client_ip if your proxy always sets it. Otherwise visitors can fake it and get round the per-connection limit.
Shortcode¶
[og_wheel]¶
Shows a wheel inline on a page.
| Attribute | Default | Meaning |
|---|---|---|
id |
newest wheel | The wheel's ID, shown on the Wheels tab. |
If the wheel does not exist, users with manage_woocommerce see a short note. Everyone else sees nothing.
Block¶
| Item | Value |
|---|---|
| Name | og-nexus/wheel |
| Title | OG LeadWheel (category Widgets) |
| Attributes | wheelId (number, default 0 = newest wheel) |
| Supports | align: wide, full |
| Rendering | Server side, through the same code as the shortcode. |
REST routes¶
Both routes are public and are what the wheel in the browser uses. Responses send Cache-Control: no-store, private.
GET /wp-json/og-wheel/v1/wheels/{id}¶
Returns what to draw. Never returns chances, stock or prize values.
| Field | Meaning |
|---|---|
id |
Wheel ID. |
live |
Whether the wheel can be spun now. |
canSpin |
false when this visitor has used their spins. |
spentMessage |
The message to show when canSpin is false. |
login |
Whether only logged-in customers can spin. |
loggedIn, email |
The current visitor's state and address (signed-in only). |
consentRequired |
Whether the consent box must be ticked. |
texts |
heading, intro, button, consent, win, lose. |
segments |
List of label, colour and text (label colour). |
loginUrl, privacyUrl |
Links shown in the wheel. |
POST /wp-json/og-wheel/v1/wheels/{id}/spin¶
Spins on the server.
| Parameter | Type | Meaning |
|---|---|---|
email |
string | Visitor's e-mail. Optional for signed-in customers (their account address is used). |
consent |
boolean | Whether the consent box was ticked. |
website |
string | Honeypot. Must be empty. |
Success:
{
"index": 2,
"won": true,
"label": "Free shipping",
"message": "You won: Free shipping",
"coupon": "OGW-7KQ2M9XT",
"emailed": true
}
Errors are WP_Error responses:
| Code | Status | Meaning |
|---|---|---|
og_wheel_missing |
404 | No such wheel. |
og_wheel_bot |
400 | The honeypot was filled in. |
og_wheel_closed |
403 | The wheel is not live. |
og_wheel_login |
401 | The wheel needs a logged-in customer. |
og_wheel_email |
400 | Invalid or too long e-mail address. |
og_wheel_consent |
400 | Consent is required and was not given. |
og_wheel_limit |
429 | A spin limit was reached. data.limit is email_total, user_total, email_daily or ip_daily. |
og_wheel_empty |
410 | Every prize is out of stock. |
og_wheel_busy |
503 | Could not get the wheel's lock within 5 seconds. |
og_wheel_error |
500 | The spin or prize could not be saved. |
MCP tools¶
The tools are served through OG AI Core's MCP server (and its Workspace and agents), which keeps MCP to administrators. They exist only while MCP tools on is ticked (option og_wheel_mcp) and OG AI Core is active. Calls also check the manage_woocommerce capability. The category is OG LeadWheel.
| Tool | Access | Arguments | What it does |
|---|---|---|---|
ogw_list_wheels |
Reads | none | Every wheel: id, name, status, live, pop-up, segment count, total spins and shortcode. |
ogw_get_wheel |
Reads | id (required) |
Full settings of one wheel, with wins per segment and any problems. |
ogw_get_stats |
Reads | id, days (1 to 365, default 30) |
Spins, prizes won, consents, unique e-mail addresses and spins per segment. Omit id for all wheels. |
ogw_list_spins |
Reads | id, search, limit (1 to 100, default 20), page |
Recent spins from the log, newest first. Contains customers' personal data. |
ogw_set_wheel_enabled |
Changes | id, enabled (both required) |
Switches a wheel on or off. Returns the new status and any problems. |
ogw_update_wheel_texts |
Changes | id, texts (both required) |
Changes heading, intro, button, consent, win or lose. An empty string restores the default. win must contain %s exactly once. |
ogw_update_segment |
Changes | id, index (both required), label, colour, weight, stock |
Changes one segment, numbered from 0. The prize type and amount stay as they are. |
The plugin adds its tools with the ogaie_mcp_tools filter and runs them through the ogaie_mcp_callback filter, both provided by OG AI Core.
Admin-post actions¶
| Action | Nonce | What it does |
|---|---|---|
og_wheel_save |
og_wheel_save |
Saves a wheel from the editor. |
og_wheel_delete |
og_wheel_delete_{id} |
Moves a wheel to the bin. |
og_wheel_export |
og_wheel_export |
Streams the spin log as CSV (wheel and s filters). |
og_wheel_mcp |
og_wheel_mcp |
Saves the MCP switch. |
All need the manage_woocommerce capability.
Admin screen¶
| Item | Value |
|---|---|
| Menu | WooCommerce › OG LeadWheel, slug og-wheel, capability manage_woocommerce |
| Tabs | admin.php?page=og-wheel&tab=log, tab=mcp, tab=more. No tab opens Wheels; the old tab=licence opens More from OG Nexus. |
| Editor | &action=new, or &action=edit&id={id} |
| Preview | &preview={id} |
| Old log address | admin.php?page=og-wheel-log redirects to the Spin log tab. |
Storage¶
Wheels¶
Each wheel is a private post of type og_wheel. The post title is the wheel's name. All settings are in one post meta field, _og_wheel_config.
Wheel settings¶
| Key | Type | Default |
|---|---|---|
enabled |
bool | false |
start, end |
string | '' (UTC Y-m-d H:i:s, or empty) |
segments |
array | Six starter segments |
limits |
array | email_total 1, user_total 0, email_daily 0, ip_daily 3 (0 = no limit, max 1000) |
login |
bool | false |
consent_required |
bool | false |
coupon |
array | expiry_days 7, min_spend 0, individual_use true, exclude_sale false |
email |
bool | true |
texts |
array | heading, intro, button, consent, win, lose, all '' (empty = translated default) |
popup |
array | enabled false, trigger delay (delay, scroll, exit), delay 8, scroll 50, pages all (all, shop, front), audience all (all, guests), snooze 7 |
Segment keys¶
| Key | Type | Values |
|---|---|---|
label |
string | Up to 40 characters |
colour |
string | Hex colour |
type |
string | none, percent, fixed, free_shipping, credits |
amount |
float | Discount or credits |
credit_kind |
string | points, ai, money (credits only) |
weight |
int | Relative chance, 0 to 1,000,000 |
stock |
int | Most wins, 0 = no limit |
Spin log table: {prefix}og_wheel_spins¶
| Column | Type | Meaning |
|---|---|---|
id |
bigint | Spin ID. |
wheel_id |
bigint | Wheel post ID. |
email |
varchar(190) | Lower-case address. Empty after erasure. |
user_id |
bigint | Customer account, or 0. |
ip_hash |
char(64) | HMAC-SHA256 of the IP address, never the raw address. |
segment_index |
smallint | Segment number, from 0. |
segment_label |
varchar(80) | Label at the time of the spin. |
prize_type |
varchar(20) | Segment type. |
prize_amount |
decimal(12,2) | Amount at the time of the spin. |
coupon_code |
varchar(40) | Coupon code, if any. |
credit_kind |
varchar(10) | Credit kind, if any. |
status |
varchar(20) | awarded, no_prize, failed or pending. |
consent |
tinyint | 1 when the consent box was ticked. |
consent_version |
varchar(12) | Fingerprint of the consent wording. |
created_at |
datetime | UTC. |
Coupon meta¶
Each prize coupon carries _og_wheel_spin (spin ID) and _og_wheel_id (wheel ID).
Options¶
| Option | What it holds |
|---|---|
og_wheel_db_version |
Spin log table version. |
og_wheel_mcp |
1 when the MCP tools are on. |
og_wheel_account_endpoint_flushed |
The My Account endpoint the rewrite rules were last flushed for. |
Constants¶
| Constant | Where to set it | What it does |
|---|---|---|
OG_WHEEL_REMOVE_DATA |
wp-config.php |
true makes uninstall delete every wheel, drop the spin log table and remove the plugin's options. |
OG_WHEEL_VERSION |
Set by the plugin | The running version. |
OG_WHEEL_FILE |
Set by the plugin | Full path to the main plugin file. |
OG_WHEEL_DIR |
Set by the plugin | Plugin folder path, with a trailing slash. |
OG_WHEEL_URL |
Set by the plugin | Plugin folder URL, with a trailing slash. |
My Account tab¶
The Wheel prizes tab lives at /my-account/wheel-prizes/ (change it with og_wheel_account_endpoint). When OG Account Customiser is active, the tab is registered through its og_account_register_tab() API on the og_account_customiser_register_tabs action, so shop owners can rename, move or hide it there. Otherwise it uses WooCommerce's own account endpoint hooks.
Privacy hooks¶
| Hook | Key | What it does |
|---|---|---|
| Personal data exporter | og-wheel |
Exports date, e-mail, result, coupon and consent for each spin. |
| Personal data eraser | og-wheel |
Clears email, user_id and ip_hash on the matching spin rows. The rows stay for prize and stock counts. |
| Privacy policy content | OG LeadWheel | A suggested paragraph under Settings › Privacy. |
Front-end script¶
The wheel is drawn by assets/js/og-wheel.js (handle og-wheel, deferred, in the footer), with styles in assets/css/og-wheel.css (handle og-wheel).
| Item | Meaning |
|---|---|
window.ogWheel |
Config printed before the script: api (REST base), nonce (signed-in visitors only), i18n strings and shop URL. |
window.ogWheelBlock |
Block editor only: { wheels: [{ value, label }] }. |
.og-wheel[data-og-wheel] |
Wheel container. data-mode is inline, popup or preview. Pop-ups also carry data-trigger, data-delay, data-scroll and data-snooze. |
html.og-wheel-open |
Class on <html> while a pop-up is open. |
ogWheelSnooze{id} |
localStorage key holding the time until a closed pop-up may show again. With a snooze of 0, sessionStorage is used for the visit only. |
| Events | None. Use the PHP actions above. |
Uninstall¶
By default, uninstall.php keeps everything. With OG_WHEEL_REMOVE_DATA set to true, it deletes all og_wheel posts, drops {prefix}og_wheel_spins, and deletes og_wheel_db_version and og_wheel_account_endpoint_flushed. Coupons are never removed. The og_wheel_mcp option is not removed.