Page Assets
Global asset loading starts in wp-content/themes/balinot/modules/00-enqueue.php.
Always loaded:
- assets/dist/theme.css as the main frontend stylesheet.
- assets/js/theme.js as the main frontend script.
Context-aware loading:
- theme_frontend_enqueue_context() builds the current page context.
- theme_context_matches_asset_rule() checks asset rules by slug, template, or context flags.
- The rule map lives in the wp_enqueue_scripts callback inside modules/00-enqueue.php.
Current examples:
- account.css for Woo account pages.
- checkout.css for cart and checkout.
- thank-you.css for order received pages.
- about.css and about.js for the about page.
- contact-form.css and contact-form.js for the contact page.
- stores-map.css and stores-map.js for the stores page.
How to add CSS or JS for one page:
- Create assets/css/my-page.css and optionally assets/js/my-page.js.
- Add a new rule to the theme_asset_rules array in modules/00-enqueue.php.
- Match the page by one of these keys:
- page_slugs
- templates
- context_flags
- Set style or script to true.
Example rule:
'catalogo' => [
'style' => true,
'script' => true,
'page_slugs' => ['catalogo'],
],Special case: Contact Form 7 assets.
- wp-content/themes/balinot/modules/20-forms.php adds extra contact form assets only when needed.
- It loads on the contacto page, when a singular post contains a Contact Form 7 shortcode, or when the ACF field shortcode_cf7 is present.
Special case: product-card.js.
- It is not loaded from 00-enqueue.php.
- functions.php loads it only for home, Woo catalog, and Woo single contexts.
Last updated on