WIACPSite theme 0.2.0-alpha.92
Türkçe

§5.8

Tracking codes, custom CSS and performance

  • Phase 10.8a
  • theme 1.8.0

The theme writes no templates for these features; the core places the output at the output points. The theme's only job is to keep the required output points of §13.

Feature Where it is printed What it means for the theme
Tracking codes (GA4, GTM, Meta Pixel, Clarity, custom JS) SiteHeadEnd → $page['head'] {!! $page['head'] !!} must be inside </head>. Codes depend on cookie consent: without a decision they are printed as <script type="text/plain" data-consent="…"> and wiacp-consent.js runs them once allowed. Do not hard-code your own analytics in the theme; the administrator uses Settings › SEO › Tracking codes.
Custom CSS SiteBodyStart → <link rel="stylesheet" href="/tema-ozel.css?v=…" data-custom-css> @hook('SiteBodyStart') must come right after <body>, so the administrator's CSS loads after the theme styles and overrides a rule of the same specificity. The value is stored in the theme.client.<theme>.custom_css setting; a theme update does not delete it, and when the theme changes that theme's value is used.
Content security policy Core Only the addresses of configured providers are added to script-src / connect-src. The theme's own scripts must stay in assets/js files (no inline scripts).

Not accepted in custom CSS: @import, @charset, @namespace, expression(), behavior, -moz-binding, javascript: / vbscript:, HTML tags, backslash escapes and url() addresses other than https:// or a site path; at most 20,000 characters.

Performance rules:

  • theme_asset() adds a version (?v=<theme version>) to the address. A file you preload (rel="preload") must be requested in CSS with the same address; otherwise the browser downloads it twice. The default theme writes the version in its @font-face addresses (inter-…woff2?v=1.8.0); update these addresses when you raise the theme version.
  • On Apache, versioned static files are cached for 7 days and unversioned ones for 1 hour (root .htaccess). If you change a file by hand, raise the theme version. On Nginx, add equivalent Cache-Control headers yourself.
  • Templates cannot reach the database; product groups, product prices and domain prices are loaded in the core with bulk queries, and panel menu counts are calculated once per request. Each helper call still runs queries; instead of calling the same helper (site_product_groups(), site_tlds() etc.) several times on a page with the same parameters, keep the result in a variable.
  • A link / button made only of an icon (for example one whose text is hidden on narrow screens) must carry aria-label.