Developer guide

Architecture, stored data, endpoints, templates, CSS hooks and how to add your own tabs through the tab source interface.

FreePro

Architecture

FreePro
NamespaceSiteryn\SiterynProductTabManagerSiterynPro\SiterynProductTabManager
BootPlugin::run() once WooCommerce is confirmed, then siteryn_ptm_loadedBoots on siteryn_ptm_loaded, then fires siteryn_ptm_pro_loaded; tabs, rules and shortcodes run only while licensed
Extension APISITERYN_PTM_API_VERSION / Plugin::API_VERSION = 1.0.0Requires Free 1.0.0 and API 1.0.0
Handlessiteryn-ptm (storefront CSS), siteryn-ptm-admin (admin CSS and JS)siteryn-ptm-pro (shortcode CSS and JS), siteryn-ptm-pro-admin
Settings pageadmin.php?page=siteryn-product-tab-manager, tabs general, tabs, style, go_premium, system_statusSame page, tabs pro_tabs, pro_rules, pro_license
Capabilitymanage_woocommercemanage_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:

PriorityStep
10TabRegistry adds registered tab sources (the custom tab, Pro tabs) that are on and have content
20TabLayout applies the Product Tabs list: removes switched-off tabs, sets titles, sets priority to 10, 20, 30…
30ProductOverrides applies the product's own titles and hidden tabs
40Pro 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

NameWhat
siteryn_ptm_settingsFree settings: enabled, tab_layout (list of key, enabled, title), custom_tab_content, the style settings and _schema
siteryn_ptm_versionInstalled 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_settingsPro tabs (up to 30) and rules (up to 100), not autoloaded
siteryn_ptm_pro_versionInstalled Pro version
siteryn_license_product-tab-manager_key, _status, _update; transients _retry, _lockLicense key, last confirmed status, cached update offer, back-off and request lock
widget_siteryn_ptm_pro_product_tabsSiteryn Product Tabs widget instances
WP-Cron siteryn_ptm_pro_license_checkDaily 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

ActionPurpose
siteryn_ptm_save_settingsSaves one settings tab (Free or Pro option) with the tab's Settings API nonce, manage_woocommerce
admin-post.php?action=siteryn_ptm_reset_settingsResets one Free tab (section), or everything with all
admin-post.php?action=siteryn_ptm_pro_reset_settingsClears Pro tabs (pro_tabs) or rules (pro_rules); refused without a license
siteryn_ptm_pro_license_action with do = activate, deactivate, refreshLicense actions
siteryn_deactivation_feedbackOptional deactivation survey (Plugins screen)

There are no storefront AJAX calls.

Templates

TemplateTheme copyVariables in $args
custom-tab.php (Free)yourtheme/siteryn-product-tab-manager/custom-tab.phpkey, tab, product, source, title, content (formatted HTML)
pro-product-tabs.php (Pro)yourtheme/siteryn-product-tab-manager/pro-product-tabs.phppanels (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

ClassWhere
body.siteryn-ptmProduct pages where the stylesheet loads
.siteryn-ptm--styledOn 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-contentCustom tab and Pro tab content
.siteryn-ptm-pro-specsPro specifications table
.siteryn-ptm-pro-tabs, --tabs, --accordion, --content; __heading, __list, __item, __summary, __panelPro 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:

EventDetailWhen
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.