Skip to main content

Theme Hooks Reference (flavor_*)

All hooks use the flavor_ prefix. Parameters shown with types.


Layout Hooks

These hooks fire in order during header rendering:

flavor_header_before
<header>
flavor_header_start
[...header content...]
flavor_header_end
</header>
flavor_header_after
<main>
flavor_content_before
HookParametersDescription
flavor_header_beforeBefore the <header> element
flavor_header_startStart of <header>, before header content
flavor_header_endEnd of <header>, after header content
flavor_header_afterAfter <header> closes
add_action('flavor_header_before', function() {
echo '<div class="announcement-bar">Free shipping over 50EUR!</div>';
});

These hooks fire in order during footer rendering:

flavor_content_after
</main>
flavor_footer_before
<footer>
flavor_footer_start
[...footer content...]
flavor_footer_widgets
flavor_footer_social
flavor_footer_end
</footer>
flavor_footer_after
HookParametersDescription
flavor_content_beforeAfter header, before main content area
flavor_content_afterAfter main content, before footer
flavor_footer_beforeBefore the <footer> element
flavor_footer_startStart of <footer>
flavor_footer_widgetsInside footer widget area
flavor_footer_socialIn footer social links area
flavor_footer_endEnd of <footer>
flavor_footer_afterAfter <footer> closes
flavor_render_footerTriggers footer template rendering (internal)
add_action('flavor_footer_before', function() {
echo '<div class="pre-footer-cta">Subscribe to our newsletter!</div>';
});

add_action('flavor_footer_widgets', function() {
echo '<div class="footer-trust-badges">...</div>';
});

eCommerce Page Hooks

Shop / Product Listing

HookParametersDescription
flavor_shop_beforeBefore shop/product listing content
flavor_shop_afterAfter shop/product listing content
add_action('flavor_shop_before', function() {
echo '<div class="shop-promotion-banner">Summer Sale — 20% off!</div>';
});

Single Product

HookParametersDescription
flavor_single_product_beforeBefore single product content
flavor_single_product_summaryInside product summary (after title/price, before tabs)
flavor_single_product_tabsIn product tabs area
flavor_product_actions$productIn product actions area (add to cart, wishlist, etc.)
flavor_single_product_relatedIn related products area
flavor_single_product_afterAfter all single product content
add_action('flavor_single_product_summary', function() {
echo '<div class="trust-badges"><img src="..." alt="Secure checkout" /></div>';
});

add_action('flavor_product_actions', function($product) {
echo '<button class="size-guide-btn" data-product="' . esc_attr($product->id) . '">Size Guide</button>';
});

Categories

HookParametersDescription
flavor_categories_beforeBefore categories listing
flavor_categories_afterAfter categories listing

Cart

HookParametersDescription
flavor_cart_beforeBefore cart content
flavor_cart_afterAfter cart content
add_action('flavor_cart_before', function() {
echo '<div class="free-shipping-progress">Add 15EUR more for free shipping!</div>';
});

Checkout

HookParametersDescription
flavor_checkout_beforeBefore checkout form
flavor_checkout_afterAfter checkout form
add_action('flavor_checkout_before', function() {
echo '<div class="checkout-trust"><span>Secure 256-bit SSL Checkout</span></div>';
});

Order Received

HookParametersDescription
flavor_order_received_beforeBefore order received / thank you page
flavor_order_received_afterAfter order received / thank you page

My Account

HookParametersDescription
flavor_account_beforeBefore my-account page content
flavor_account_afterAfter my-account page content

Theme Lifecycle Hooks

Actions

HookParametersDescription
flavor_initialized$bootstrapAfter theme DDD bootstrap completes
flavor_register_services$containerDuring theme service registration
flavor_components_loaded$bootstrapAfter all theme components are loaded
flavor_register_translationsWhen the translation system initializes — register custom strings here
flavor_register_modules$managerWhen the module manager collects modules (Module System 2.0) — register custom modules here
add_action('flavor_initialized', function($bootstrap) {
// Theme is ready — safe to interact with theme services
});

Registering a custom module (Module System 2.0)

Modules are classes extending Flavor\Modules\AbstractModule. Register them by class name on flavor_register_modules; the manager reads all metadata from the class itself:

add_action('flavor_register_modules', function($manager) {
$manager->register(\MyVendor\Modules\MyCustomModule::class);
});

Translatable Strings

The theme has its own translation registry (independent of WordPress i18n, backed by the theme's own DB table). Register strings on flavor_register_translations, then read them with flavor_t() / flavor_te().

add_action('flavor_register_translations', function() {
// Batch register (recommended)
Flavor_Translation_Registry::registerMany([
'my_plugin.welcome' => 'Welcome to our store',
'my_plugin.cta' => 'Shop now',
]);

// …or a single string with optional translator context
Flavor_Translation_Registry::register('my_plugin.badge', 'New', 'Product badge label');
});

// Read the (possibly translated) value:
echo flavor_t('my_plugin.welcome'); // returns the string
flavor_te('my_plugin.cta'); // echoes it, HTML-escaped

Keys are dot-namespaced (vendor.area.item); the first segment groups strings in the Translations admin screen. flavor_t($key, $default) falls back to $default (or the key itself) when a key is unregistered.

caution
flavor_register_string() does not exist

Earlier drafts referenced a flavor_register_string() helper — there is no such function. Always register through Flavor_Translation_Registry::register() / ::registerMany() inside a flavor_register_translations callback, and read with flavor_t() / flavor_te().


Page Builder Hooks

HookTypeParametersDescription
flavor_builder_register_dynamic_tagsaction$registryRegister custom dynamic tags for the Visual Page Builder. $registry is the DynamicTags instance.
flavor_builder_post_typesfilter$postTypesWhich post types support the Visual Page Builder (see Filters)
add_action('flavor_builder_register_dynamic_tags', function($registry) {
// $registry->addTag(...) — expose a custom dynamic value to builder blocks
});

Module Hooks

Stock Alerts

HookParametersDescription
flavor_stock_alert_subscribed$productId, $email, $variantIdCustomer subscribes to stock alert
flavor_stock_alert_sent$alertId, $alertStock alert email sent

Request Quote

HookParametersDescription
flavor_quote_created$quoteIdNew quote request submitted
flavor_quote_responded$quoteIdMerchant responds to quote
flavor_quote_accepted$quoteIdCustomer accepts quote
flavor_quote_converted$quoteId, $orderIdAccepted quote converted to order

PDF Invoices

HookParametersDescription
flavor_invoice_generated$invoiceId, $orderIdPDF invoice generated

Points & Rewards

HookParametersDescription
flavor_points_transaction_added$customerId, $points, $type, $sourceLoyalty points added/deducted
add_action('flavor_points_transaction_added', function($customerId, $points, $type, $source) {
if ($points > 100) {
send_milestone_notification($customerId, $points);
}
}, 10, 4);

Newsletter

HookParametersDescription
flavor_newsletter_subscribed$email, $nameUser subscribes via the newsletter block
flavor_hfb_newsletter_subscribed$email, $endpoint, $responseUser subscribes via a Header/Footer Builder newsletter element; $endpoint is the target service and $response its raw reply
add_action('flavor_newsletter_subscribed', function($email, $name) {
mailchimp_add_subscriber($email, $name);
}, 10, 2);

Abandoned Cart

HookParametersDescription
flavor_abandoned_cart_email_sent$cartId, $emailNumberRecovery email sent (sequence: 1, 2, 3)

Contact Form

HookParametersDescription
flavor_form_submitted$formId, $data, $formContact form submitted
add_action('flavor_form_submitted', function($formId, $data, $form) {
crm_create_lead($data['email'], $data['name'], $data['message']);
}, 10, 3);

Product Bundles

HookParametersDescription
flavor_add_to_cart$productId, $variantId, $quantityBundle component added to cart

Theme Filters

flavor_initial_state

Modify the initial state object passed to the React frontend.

ParameterTypeDescription
$statearrayThe state array (settings, translations, cart data, etc.)
add_filter('flavor_initial_state', function($state) {
$state['myPlugin'] = [
'apiUrl' => rest_url('my-plugin/v1/'),
'settings' => get_my_plugin_settings(),
];
return $state;
});

flavor_cart_totals

Modify cart totals before display (sidebar cart and cart page).

ParameterTypeDescription
$totalsarrayThe totals array (subtotal, shipping, tax, total, etc.)
$cartCart|nullThe cart entity
add_filter('flavor_cart_totals', function($totals, $cart) {
if ($totals['subtotal'] < 30) {
$totals['handling_fee'] = 2.50;
$totals['total'] += 2.50;
}
return $totals;
}, 10, 2);

Modify popular/suggested search terms shown in the search modal.

ParameterTypeDescription
$termsarrayArray of search term strings
add_filter('flavor_popular_search_terms', function($terms) {
return ['New Arrivals', 'Sale', 'Best Sellers', 'Gift Cards'];
});

flavor_no_image_url

Modify the placeholder image URL when a product has no image.

ParameterTypeDescription
$urlstringThe placeholder image URL
$widthintRequested image width
$heightintRequested image height
$contextstringUsage context ('product', 'category')
add_filter('flavor_no_image_url', function($url, $width, $height, $context) {
if ($context === 'product') {
return get_template_directory_uri() . '/assets/img/no-product.svg';
}
return $url;
}, 10, 4);

flavor_builder_post_types

Modify which post types support the Visual Page Builder.

ParameterTypeDescription
$postTypesarrayArray of supported post type slugs (default: ['page'])
add_filter('flavor_builder_post_types', function($postTypes) {
$postTypes[] = 'portfolio';
return $postTypes;
});

flavor_editor_post_types

Modify which post types use the Tiptap rich-text editor.

ParameterTypeDefaultDescription
$postTypesarray['post', 'page']Post types that load the Tiptap editor

flavor_content_width

Modify the global content width.

ParameterTypeDefaultDescription
$widthint1200Content width in pixels

flavor_smart_asset_rules

Modify smart asset loading rules (conditional CSS/JS loading).

ParameterTypeDescription
$rulesarrayArray of asset loading rules

flavor_options_readonly

Control whether theme options are read-only (e.g., sandbox/demo mode).

ParameterTypeDefaultDescription
$readonlyboolfalseWhether options are read-only

flavor_header_elements

Modify available header builder elements.

ParameterTypeDescription
$elementsarrayArray of header element definitions

Override whether marketing consent is required for tracking.

ParameterTypeDescription
$requiredboolWhether consent is required

Override whether the current user has given marketing consent.

ParameterTypeDescription
$hasConsentboolWhether user has consented

flavor_cart_subtotal

Provide cart subtotal for modules (e.g., B2B minimum order checks).

ParameterTypeDefaultDescription
$subtotalfloat0The cart subtotal

flavor_get_cart_product_ids

Provide current cart product IDs for modules (e.g., upsell/cross-sell exclusions).

ParameterTypeDefaultDescription
$productIdsarray[]Array of product IDs in cart

flavor_ai_image_download_hosts

Allowlist of hosts the AI Content helper may download images from. Add a host to permit fetching AI-sourced imagery from it.

ParameterTypeDescription
$allowedHostsarrayArray of allowed hostnames
add_filter('flavor_ai_image_download_hosts', function($hosts) {
$hosts[] = 'cdn.my-approved-source.com';
return $hosts;
});

flavor_secret_option_keys

Declare additional theme-option keys that must be treated as secret (stored encrypted-at-rest, masked in exports). Advanced — use when an extension stores credentials in theme options.

ParameterTypeDescription
$keysarrayArray of option keys treated as secret
add_filter('flavor_secret_option_keys', function($keys) {
$keys[] = 'my_module_api_secret';
return $keys;
});