Developer guide
Add the accordion to a theme, support the shop sidebar, override its templates and react to it in JavaScript.
Architecture
| Free | Pro | |
|---|---|---|
| Namespace | Siteryn\SiterynCategoryAccordion | SiterynPro\SiterynCategoryAccordion |
| Boot | siteryn_sca_loaded | siteryn_sca_pro_loaded |
| Handles | siteryn-sca (CSS and JS) | siteryn-sca-pro (CSS and JS) |
| Settings option | siteryn_sca_settings | siteryn_sca_pro_settings |
| Widget ID base | siteryn_sca_category_accordion | Block siteryn/category-accordion |
Every placement goes through Accordion::parse_args() (saved settings, then placement overrides, then the siteryn_sca_accordion_args filter), CategoryRepository::get_tree() and the two templates. Pro adds its settings to the arguments under $args['pro'] and works only through Free's hooks.
Template tag
<?php siteryn_sca_category_accordion(); ?> <?php siteryn_sca_category_accordion( array( 'parent' => 'dresses', 'depth' => 2, 'default_state' => 'expanded' ) ); ?>
Echoes the accordion (or nothing when it's disabled or empty) and loads its assets. Accepts the shortcode attributes as keys; with Pro also layout, show_counts, show_thumbnails, auto_open_active, ajax_children and current_branch_only.
Theme support for the shop sidebar
if ( function_exists( 'siteryn_sca_use_in_shop_sidebar' ) && siteryn_sca_use_in_shop_sidebar() ) {
ob_start();
siteryn_sca_category_accordion();
$accordion = trim( ob_get_clean() );
}
// Print $accordion if it is not empty; otherwise print your own category list.
siteryn_sca_use_in_shop_sidebar() returns the Use in Shop Sidebar setting. Keep your own list as the fallback for when it returns false or the accordion prints nothing.
Templates
| Template | Variables |
|---|---|
category-accordion.php | $args, $tree, $context, $instance_id, $classes, $current_id |
category-accordion-item.php | $node, $term, $args, $instance_id, $current_id, $depth, $has_children, $is_open, $is_current, $link, $children_id, $item_classes |
Copy them to your-theme/siteryn-category-accordion/. Keep the data-siteryn-sca* attributes, the toggle buttons' aria-controls and the @version header: outdated copies trigger an admin notice. $context is template, shortcode, widget, block, elementor, bricks or preview.
Markup
- Container:
nav.siteryn-scawithsiteryn-sca--{context},--icon-{left|right},--toggle-{plus|chevron|caret},--click-{link|toggle},--dividers; Pro addssiteryn-sca--layout-{layout}andsiteryn-sca-pro-*classes. - Items:
li.siteryn-sca__item.siteryn-sca__item--depth-{n}withhas-children,is-open,is-current; Pro addsis-active-category,is-current-ancestorandsiteryn-sca-pro-lazy. - Style settings are CSS variables on
.siteryn-sca, such as--siteryn-sca-text,--siteryn-sca-font-size,--siteryn-sca-child-indent,--siteryn-sca-duration.
JavaScript API and events
const item = document.querySelector( '.siteryn-sca [data-term-id="15"]' ); window.siterynScaAccordion.open( item ); // also close( item ), toggle( item )
| Event (on the item, bubbles) | When |
|---|---|
siteryn-sca:beforeopen | Before opening; preventDefault() cancels |
siteryn-sca:open | After it starts opening |
siteryn-sca:beforeclose | Before closing; preventDefault() cancels |
siteryn-sca:close | After it starts closing |
event.detail.item is the li. Clicks are handled with one delegated listener, so accordions added later work too.
Assets
Assets are enqueued early on pages that will show the accordion (see Performance), otherwise when it renders. Force them with add_filter( 'siteryn_sca_enqueue_assets', '__return_true' ), and add your own on siteryn_sca_enqueue_frontend_assets.
Endpoints
| Action | Access | Use |
|---|---|---|
siteryn_sca_pro_children | Public (logged in or not), POST, signed payload | Pro AJAX loading: payload, sig, term_id, depth, instance → {html} |
siteryn_sca_save_settings · siteryn_sca_reset_settings (admin-post) · siteryn_sca_pro_license_action | manage_woocommerce + nonce | Settings screen |
The Plugins screen's deactivation survey uses its own admin AJAX action (activate_plugins + nonce). No REST routes; the block renders on the server.
Data
- Options:
siteryn_sca_settings,siteryn_sca_version,widget_siteryn_sca_category_accordion,siteryn_sca_pro_settings,siteryn_sca_pro_version,siteryn_license_category-accordion_key/_status/_update. - Transient
siteryn_sca_outdated_templates(1 day). No post meta, tables, cron or custom capabilities. - Uninstalling removes each plugin's own options.
wp-config constants
| Constant | Effect |
|---|---|
SCRIPT_DEBUG | Unminified CSS |
SITERYN_FEEDBACK_ENDPOINT | Where the deactivation survey is sent (default https://siteryn.com/wp-json/siteryn/v1/feedback/deactivation) |
SITERYN_SCA_PRO_LICENSE_API_BASE | License server URL (default https://siteryn.com/wp-json/siteryn/v1) |