Developer guide
Architecture, stored data, endpoints, templates, CSS hooks and how to add your own tabs through the tab source interface.
Architecture
| Free | Pro | |
|---|---|---|
| Namespace | Siteryn\SiterynProductTabManager | SiterynPro\SiterynProductTabManager |
| Boot | Plugin::run() once WooCommerce is confirmed, then siteryn_ptm_loaded | Boots on siteryn_ptm_loaded, then fires siteryn_ptm_pro_loaded; tabs, rules and shortcodes run only while licensed |
| Extension API | SITERYN_PTM_API_VERSION / Plugin::API_VERSION = 1.0.0 | Requires Free 1.0.0 and API 1.0.0 |
| Handles | siteryn-ptm (storefront CSS), siteryn-ptm-admin (admin CSS and JS) | siteryn-ptm-pro (shortcode CSS and JS), siteryn-ptm-pro-admin |
| Settings page | admin.php?page=siteryn-product-tab-manager, tabs general, tabs, style, go_premium, system_status | Same page, tabs pro_tabs, pro_rules, pro_license |
| Capability | manage_woocommerce | manage_woocommerce |
The tab pipeline
Free hooks WooCommerce's woocommerce_product_tabs at priority 98 (after WooCommerce's default tabs at 10, before its sorting at 99) and passes the tabs through one filter, siteryn_ptm_product_tabs, with the current product:
| Priority | Step |
|---|---|
| 10 | TabRegistry adds registered tab sources (the custom tab, Pro tabs) that are on and have content |
| 20 | TabLayout applies the Product Tabs list: removes switched-off tabs, sets titles, sets priority to 10, 20, 30… |
| 30 | ProductOverrides applies the product's own titles and hidden tabs |
| 40 | Pro RuleEngine applies Tab Rules (only while licensed) |
Hook in at 40+ to refine the final result. Keep WooCommerce's shape (title, priority, callback) and never replace the callback of a tab you don't own: the Product Details block recognises core tabs by their callback. The pipeline is skipped when Enable Tab Manager is off.
add_filter( 'siteryn_ptm_product_tabs', function ( $tabs, $product ) {
if ( isset( $tabs['reviews'] ) && 0 === $product->get_review_count() ) {
unset( $tabs['reviews'] );
}
return $tabs;
}, 50, 2 );
Adding tabs with a tab source
A tab source is a class implementing Contracts\TabSourceInterface, usually by extending Tabs\AbstractTabSource. Registered sources get a row in the Product Tabs list, rename/reorder/hide, a group in the product's Product Tabs panel, the Live Preview, safe content formatting and the custom-tab.php template, without extra code.
use Siteryn\SiterynProductTabManager\Tabs\AbstractTabSource;
use Siteryn\SiterynProductTabManager\Tabs\TabRegistry;
class My_Warranty_Tab extends AbstractTabSource {
public function get_key() { return 'my_warranty'; } // unique, sanitize_key()-safe
public function get_label() { return 'Warranty'; } // name in the admin list
public function get_default_title() { return 'Warranty'; } // title on the product page
protected function get_default_content( $product ) {
return '<p>Two-year warranty on every order.</p>';
}
}
add_action( 'siteryn_ptm_register_tab_sources', function () {
TabRegistry::register( new My_Warranty_Tab() );
} );
Defaults from AbstractTabSource: off until switched on (is_enabled_by_default() false), per-product content supported, template custom-tab.php, priority 40. A key that clashes with a WooCommerce tab or another source is rejected with a _doing_it_wrong notice.
Data stored
| Name | What |
|---|---|
siteryn_ptm_settings | Free settings: enabled, tab_layout (list of key, enabled, title), custom_tab_content, the style settings and _schema |
siteryn_ptm_version | Installed Free version |
siteryn_ptm_outdated_templates (transient) | Cached list of outdated theme template copies (one day) |
_siteryn_ptm_product_tabs (product meta) | { version: 1, tabs: { key: { title?, hidden?, content? } } }; deleted when empty |
siteryn_ptm_pro_settings | Pro tabs (up to 30) and rules (up to 100), not autoloaded |
siteryn_ptm_pro_version | Installed Pro version |
siteryn_license_product-tab-manager_key, _status, _update; transients _retry, _lock | License key, last confirmed status, cached update offer, back-off and request lock |
widget_siteryn_ptm_pro_product_tabs | Siteryn Product Tabs widget instances |
WP-Cron siteryn_ptm_pro_license_check | Daily license check |
Uninstalling removes the items above (Free's on deleting Free, Pro's on deleting Pro), on every site of a network.
AJAX and admin-post endpoints
| Action | Purpose |
|---|---|
siteryn_ptm_save_settings | Saves one settings tab (Free or Pro option) with the tab's Settings API nonce, manage_woocommerce |
admin-post.php?action=siteryn_ptm_reset_settings | Resets one Free tab (section), or everything with all |
admin-post.php?action=siteryn_ptm_pro_reset_settings | Clears Pro tabs (pro_tabs) or rules (pro_rules); refused without a license |
siteryn_ptm_pro_license_action with do = activate, deactivate, refresh | License actions |
siteryn_deactivation_feedback | Optional deactivation survey (Plugins screen) |
There are no storefront AJAX calls.
Templates
| Template | Theme copy | Variables in $args |
|---|---|---|
custom-tab.php (Free) | yourtheme/siteryn-product-tab-manager/custom-tab.php | key, tab, product, source, title, content (formatted HTML) |
pro-product-tabs.php (Pro) | yourtheme/siteryn-product-tab-manager/pro-product-tabs.php | panels (key => title, html), product, layout, open, heading, id, classes |
Both carry an @version tag (1.0.0). When your copy of custom-tab.php is older than the plugin's, store managers see "Siteryn Product Tab Manager template files should be updated" in the admin. custom-tab.php prints the tab title as an h2 (turn it off with siteryn_ptm_custom_tab_show_heading) and the content in div.siteryn-ptm-tab-content.siteryn-ptm-tab-content--{key}, filtered through wp_kses().
Tab content is formatted like post content (wptexturize, wpautop, shortcodes) through the siteryn_ptm_tab_content filter; Pro adds video auto-embeds for rich tabs.
CSS classes and variables
| Class | Where |
|---|---|
body.siteryn-ptm | Product pages where the stylesheet loads |
.siteryn-ptm--styled | On body while the Siteryn tab style is on |
.siteryn-ptm--preset-{underline|boxed|pills}, --align-{left|center|justify}, --mobile-{scroll|stack} | Style, Alignment and On small screens |
.siteryn-ptm-tab-content | Custom tab and Pro tab content |
.siteryn-ptm-pro-specs | Pro specifications table |
.siteryn-ptm-pro-tabs, --tabs, --accordion, --content; __heading, __list, __item, __summary, __panel | Pro shortcode, widget and template tag output |
The style's values are CSS variables on .siteryn-ptm--styled: --siteryn-ptm-text, --siteryn-ptm-active-text, --siteryn-ptm-tab-bg, --siteryn-ptm-active-bg, --siteryn-ptm-accent, --siteryn-ptm-accent-text, --siteryn-ptm-border, --siteryn-ptm-panel-bg, --siteryn-ptm-font-size, --siteryn-ptm-radius, --siteryn-ptm-gap, --siteryn-ptm-panel-padding.
body.siteryn-ptm--styled .woocommerce-tabs ul.tabs li.active a {
font-weight: 700;
}
Admin JavaScript events
The plugin has no storefront JavaScript except Pro's shortcode tabs. On the settings screen these events fire on document:
| Event | Detail | When |
|---|---|---|
siteryn-ptm:admin-ready | - | The settings script is ready |
siteryn-ptm:tab-activated | { tab } | A settings tab was opened |
siteryn-ptm:settings-saved | { form } | A tab was saved |
siteryn-ptm:color-change | - | A color field changed (bubbles from the input) |
siteryn_ptm_pro_license_changed | { active } | Pro: the license was activated or deactivated on the License tab |
Extending the settings page
Add a tab with siteryn_ptm_settings_sections (give it its own option_group and option_name, or a render_callback), add fields with siteryn_ptm_settings_fields, map your option to a reset action with siteryn_ptm_settings_reset_actions, and place it in the menu with siteryn_ptm_settings_nav_group. The header save button and Reset card then work for your tab. See the Hooks reference.