Sessions 3-4 deliverables. Establishes the Asterion content pipeline :
EN pages generated programmatically from content-source/*-data.php, FR
translations rebuilt natively by Bricks's WPML integration from EN structure
+ WPML strings (no direct FR _bricks_page_content_2 writes).
## tools/_av-bricks-shared.php (the library)
Shared helpers + element atoms (eyebrow/heading/text/button/text-link) +
section builders (hero/prose/list/cards/cta/upsell/closer) + page write
pipeline that handles : write EN content via $wpdb (bypass Bricks's filter),
force Bricks::Elements::load_elements() so controls are populated, fire
wpml_page_builder_register_strings, push dict FR into icl_string_translations
(skip user CTE edits, auto-prefix /fr on internal URLs), trigger Bricks
native FR rebuild via wpml_page_builder_string_translated, and ensure a CTE
job exists (icl_translate_job.editor='wpml' + revision=NULL + populate
icl_translate rows with base64+gzip-encoded EN/FR strings).
## tools/av-generate-{industries,solutions}.php
Thin wrappers : URL trigger (template_redirect, not init — Bricks elements
load on 'wp' hook), add_filter('av_fr_translation_dict', ...) to register
FR strings, content-type-specific hub builder. ~150 FR strings per type.
## tools/av-translate-{industries,solutions}-fr.php
One-shot seeds for the initial FR linked posts via WPML trid mapping.
## tools/av-wpml-* operational mu-plugins
- set-cte : switch doc_translation_method to ICL_TM_TMETHOD_EDITOR (=1)
- create-jobs : reset CTE jobs (status=10 + needs_update=1 + editor=wpml +
revision=NULL). Integrated into pipeline via av_ensure_wpml_cte_job().
- fix-status / repair : align FR posts to correct trid + cleanup orphans.
- push-translations : push dict into icl_string_translations.
- plugins-check / debug / dump-strings / icl-dump / rescan : diagnostics.
## tools/av-fix-link-types.php
One-shot DB migration : convert legacy link.type='internal'+url to 'external'
across all _bricks_page_*_2 meta values (JSON and PHP-serialized). Bricks's
set_link_attributes() only renders href= for type='external' — older session-3
templates lost their href silently.
## Other tools/ mu-plugins
- av-bricks-rest-bridge : pivot — exposes Bricks CPTs over REST, dual-format
read filter (JSON for MCP / array for renderer), auto-mirror content→header/
footer for templates.
- av-apply-bricks-styles, av-cleanup-orphans, av-create-wp-menu, av-debug-meta,
av-dump-bricks, av-fix-template-meta : misc operational scripts.
## Bricks Config/
JSON snapshots of bricks_theme_styles, bricks_color_palette,
bricks_global_settings for diffable inspection.
## .gitignore
Add .mcp.json — holds per-developer WP App Password for the Bricks MCP server.
## wp-content/themes/asterion-bricks/assets/css/utilities.css
Note that all responsive overrides are now emitted natively by the page
generator via Bricks per-breakpoint settings, no custom CSS needed.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
69 lines
3.1 KiB
PHP
69 lines
3.1 KiB
PHP
<?php
|
|
/**
|
|
* Plugin Name: Asterion — Fix Bricks Template meta (one-shot)
|
|
* Description: Visit /?av_fix_template_meta=ID&type=header (admin only) to set _bricks_template_type and global conditions for a Bricks template. Also versionable for re-runs.
|
|
*
|
|
* Usage examples :
|
|
* /?av_fix_template_meta=25&type=header → mark template 25 as Header type, condition = entire website
|
|
* /?av_fix_template_meta=26&type=footer → mark template 26 as Footer type, condition = entire website
|
|
* /?av_fix_template_meta=42&type=section → mark as section template (no auto-condition)
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
add_action('init', function () {
|
|
|
|
if (empty($_GET['av_fix_template_meta'])) return;
|
|
if (! in_array($_SERVER['SERVER_NAME'] ?? '', ['localhost', '127.0.0.1'], true)) wp_die('localhost only');
|
|
|
|
$template_id = (int) $_GET['av_fix_template_meta'];
|
|
$type = sanitize_text_field($_GET['type'] ?? 'content');
|
|
|
|
$valid_types = ['header', 'footer', 'section', 'content', 'popup', 'archive', 'single', 'search', 'error'];
|
|
if (! in_array($type, $valid_types, true)) {
|
|
wp_die("Invalid type: $type. Must be one of: " . implode(', ', $valid_types));
|
|
}
|
|
|
|
if (get_post_type($template_id) !== 'bricks_template') {
|
|
wp_die("Post $template_id is not a bricks_template");
|
|
}
|
|
|
|
$report = [];
|
|
|
|
// 1. Set template type
|
|
update_post_meta($template_id, '_bricks_template_type', $type);
|
|
$report[] = "_bricks_template_type = $type";
|
|
|
|
// 2. Set conditions = entire website (for header/footer/archive/single/search/error templates)
|
|
// Bricks expects _bricks_template_settings with a 'templateConditions' array
|
|
// Each condition shape : ['main' => 'any'] applies on the entire site
|
|
if (in_array($type, ['header', 'footer', 'archive', 'single', 'search', 'error'], true)) {
|
|
$settings = get_post_meta($template_id, '_bricks_template_settings', true);
|
|
if (! is_array($settings)) $settings = [];
|
|
|
|
$settings['templateConditions'] = [
|
|
[
|
|
'id' => substr(md5((string) $template_id . microtime()), 0, 6),
|
|
'main' => 'any',
|
|
],
|
|
];
|
|
|
|
// Header templates : sticky on top by default unless &sticky=0
|
|
if ($type === 'header' && ($_GET['sticky'] ?? '1') !== '0') {
|
|
$settings['headerSticky'] = true;
|
|
// headerStickyOnScroll switches from position:fixed (default brx-sticky)
|
|
// to position:sticky → header flows normally on load (no content overlap),
|
|
// sticks only once user starts scrolling.
|
|
$settings['headerStickyOnScroll'] = true;
|
|
$report[] = "headerSticky = true + headerStickyOnScroll = true (.brx-sticky.on-scroll)";
|
|
}
|
|
|
|
update_post_meta($template_id, '_bricks_template_settings', $settings);
|
|
$report[] = "_bricks_template_settings.templateConditions = [{main:any}]";
|
|
}
|
|
|
|
wp_die('<pre style="font:12px/1.5 monospace;padding:2rem;background:#0B1F3A;color:#E0C892;">'
|
|
. esc_html("Template #$template_id ($type) updated:\n " . implode("\n ", $report))
|
|
. '</pre>', 'Template meta fixed');
|
|
});
|