Files
AsterionWP2026/wp-content/themes/asterion-bricks/functions.php
j.foucher 6f62082dc4 feat(child-theme): scaffold asterion-bricks v0.1.0
Initial child theme structure inheriting from Bricks parent. Token-driven,
RGPD-native, mobile-first foundation ready for component and template work.

What's in this commit
- style.css: WP theme metadata (Template: bricks, v0.1.0)
- functions.php: enqueue cascade tokens -> utilities -> components,
  defer-loaded main.js, font preload, theme support, image sizes
  (av-hero 2400x1350, av-card 800x600, av-thumb 400x300), Gutenberg
  default styles dequeued
- theme.json: Gutenberg color/typo palette mirroring tokens
- assets/css/tokens.css: full design system per Design Handoff section 2
  (brand colors, neutrals, semantics, type scale + line-heights, 8pt
  spacing, radii, shadows, z-index, motion, prefers-reduced-motion)
- assets/css/utilities.css: modern reset + .av-container, .av-skip-link,
  .av-sr-only, .av-stack, .av-section helpers, opinionated heading scale
- assets/css/components.css: index of planned components + buttons
  (5 variants x 4 sizes per Design Handoff section 3.1) and links
- assets/js/main.js: vanilla skeleton with header scroll, IntersectionObserver
  reveal, count-up, mobile drawer; respects prefers-reduced-motion
- inc/cpt.php: register_post_type case_study (slug /customers/) + scenario
  (slug /scenarios/) + shared 'industry' taxonomy
- inc/seo.php: Organization JSON-LD on home; placeholders for Product,
  Article, FAQPage, BreadcrumbList
- assets/fonts/: Inter Variable + Italic WOFF2 self-hosted (RGPD; no
  Google Fonts CDN). Inter Display @font-face commented — Inter 4+ uses
  opsz axis from the same file.

Out of scope (intentionally deferred)
- Component fills: cards, forms, navigation, alerts, modals, tabs (placeholders)
- Page templates: home and beyond
- Bricks JSON template exports
- Schema.org Product / Article / FAQPage / BreadcrumbList implementations

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 11:49:10 +02:00

158 lines
4.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* Asterion Bricks — child theme bootstrap
*
* Loads design tokens, utilities, components, and main JS in a deterministic
* order. Registers theme support, image sizes, and includes modular pieces
* (custom post types, SEO schemas).
*
* @package AsterionBricks
* @since 0.1.0
*/
defined('ABSPATH') || exit;
define('AV_THEME_VERSION', '0.1.0');
define('AV_THEME_DIR', get_stylesheet_directory());
define('AV_THEME_URI', get_stylesheet_directory_uri());
/**
* Enqueue child theme styles and scripts.
*
* Bricks parent stylesheet is loaded by the parent theme itself — no need to
* re-enqueue. We layer our tokens → utilities → components on top.
*
* Cache busting via `filemtime()` so dev changes are picked up without manual
* version bumps. In production, swap to AV_THEME_VERSION + a build step.
*/
add_action('wp_enqueue_scripts', function () {
$css_dir = AV_THEME_DIR . '/assets/css';
$css_uri = AV_THEME_URI . '/assets/css';
$js_dir = AV_THEME_DIR . '/assets/js';
$js_uri = AV_THEME_URI . '/assets/js';
if (file_exists($css_dir . '/tokens.css')) {
wp_enqueue_style(
'av-tokens',
$css_uri . '/tokens.css',
[],
filemtime($css_dir . '/tokens.css')
);
}
if (file_exists($css_dir . '/utilities.css')) {
wp_enqueue_style(
'av-utilities',
$css_uri . '/utilities.css',
['av-tokens'],
filemtime($css_dir . '/utilities.css')
);
}
if (file_exists($css_dir . '/components.css')) {
wp_enqueue_style(
'av-components',
$css_uri . '/components.css',
['av-tokens', 'av-utilities'],
filemtime($css_dir . '/components.css')
);
}
if (file_exists($js_dir . '/main.js')) {
wp_enqueue_script(
'av-main',
$js_uri . '/main.js',
[],
filemtime($js_dir . '/main.js'),
['strategy' => 'defer', 'in_footer' => true]
);
}
}, 20);
/**
* Preload self-hosted Inter fonts to reduce LCP.
*
* Only emits <link rel="preload"> for fonts that actually exist on disk —
* silent during early dev when the WOFF2 files have not been dropped yet.
*/
add_action('wp_head', function () {
$fonts = [
'Inter-Variable.woff2',
// 'InterDisplay-Variable.woff2',
];
foreach ($fonts as $font) {
$path = AV_THEME_DIR . '/assets/fonts/' . $font;
if (file_exists($path)) {
printf(
'<link rel="preload" href="%s/assets/fonts/%s" as="font" type="font/woff2" crossorigin>' . "\n",
esc_url(AV_THEME_URI),
esc_attr($font)
);
}
}
}, 1);
/**
* Modular includes.
*
* Each file is opt-in via file_exists() so partial scaffolds don't fatal.
*/
$av_includes = [
'inc/cpt.php', // Custom post types: case_study, scenario.
'inc/seo.php', // Schema.org JSON-LD overrides.
];
foreach ($av_includes as $av_include) {
$path = AV_THEME_DIR . '/' . $av_include;
if (file_exists($path)) {
require_once $path;
}
}
unset($av_include, $path);
/**
* Theme support and custom image sizes.
*
* Image sizes per Design Handoff section 8.3:
* - hero 2400×1350 (16:9)
* - card 800×600 (4:3)
* - thumb 400×300 (4:3)
*/
add_action('after_setup_theme', function () {
add_theme_support('post-thumbnails');
add_theme_support('html5', [
'search-form', 'comment-form', 'comment-list',
'gallery', 'caption', 'style', 'script',
]);
add_theme_support('responsive-embeds');
add_theme_support('align-wide');
add_theme_support('editor-styles');
add_image_size('av-hero', 2400, 1350, true);
add_image_size('av-card', 800, 600, true);
add_image_size('av-thumb', 400, 300, true);
load_child_theme_textdomain('asterion-bricks', AV_THEME_DIR . '/languages');
});
/**
* Hide the WP admin bar on frontend for non-admins (cleaner preview screenshots).
*/
add_action('after_setup_theme', function () {
if (! current_user_can('administrator')) {
show_admin_bar(false);
}
});
/**
* Disable Gutenberg block library default styles when Bricks is active —
* we own typography end-to-end through tokens.css.
*/
add_action('wp_enqueue_scripts', function () {
wp_dequeue_style('wp-block-library');
wp_dequeue_style('wp-block-library-theme');
wp_dequeue_style('global-styles');
wp_dequeue_style('classic-theme-styles');
}, 100);