chore: add tools/fresh-setup-mu-plugin for clean LocalWP recreation
Helper for resetting the dev environment by deleting the LocalWP site and
creating a fresh one (cleaner than wiping pages/options/transients in place).
tools/fresh-setup-mu-plugin.php
Drop into wp-content/mu-plugins/ of a brand-new LocalWP install named
"Asterion 2026". On first hit it:
- sets siteurl/home to http://localhost:10004 (override AV_TARGET_HOME
if LocalWP allocates a different port)
- sets pretty permalinks (/%postname%/)
- timezone Europe/Paris
- activates the Bricks parent + asterion-bricks child theme (assumes
the Junction has been re-made and the Bricks ZIP unpacked)
- activates WPML core
- sets Bricks Builder Access postTypes to page/post/case_study/scenario
- flushes rewrite rules
- self-deletes
tools/README.md
Step-by-step procedure for the LocalWP delete → recreate → junction →
unpack ZIPs → drop mu-plugin → first-hit flow. Plus the manual follow-up
for Bricks license, WPML wizard, Bricks Theme Styles.
This file path (tools/) is a deliberate sibling of content-source/ and
ThirdParty/, all of them used during setup or migration but never loaded
by the site at runtime.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
37
tools/README.md
Normal file
37
tools/README.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# Tools
|
||||
|
||||
One-shot scripts and helpers used during project setup or migrations. They are NOT part of the published site.
|
||||
|
||||
## fresh-setup-mu-plugin.php
|
||||
|
||||
Drop into `wp-content/mu-plugins/` of a freshly created LocalWP site to auto-configure WordPress for the Asterion VR project. Read its inline header for the full procedure.
|
||||
|
||||
Quick recap :
|
||||
|
||||
1. Delete the old LocalWP site (right-click → Delete site, optionally move folder to trash).
|
||||
2. Create a new LocalWP site named "Asterion 2026", mode `localhost`, default credentials.
|
||||
3. Note the allocated port — likely `10004` again. **If different, edit `AV_TARGET_HOME` in `fresh-setup-mu-plugin.php` first.**
|
||||
4. Junction the child theme into the new site:
|
||||
```powershell
|
||||
New-Item -ItemType Junction `
|
||||
-Path "C:\Users\j_foucher\Local Sites\asterion-2026\app\public\wp-content\themes\asterion-bricks" `
|
||||
-Target "C:\ASTERION\GIT\WP2026\wp-content\themes\asterion-bricks"
|
||||
```
|
||||
5. Extract the Bricks parent theme: `Expand-Archive ThirdParty\bricks.2.3.4.zip "<NEW_SITE>\app\public\wp-content\themes\"`
|
||||
6. Extract WPML: `Expand-Archive ThirdParty\sitepress-multilingual-cms.4.9.3.zip "<NEW_SITE>\app\public\wp-content\plugins\"`
|
||||
7. Copy `tools/fresh-setup-mu-plugin.php` → `<NEW_SITE>\app\public\wp-content\mu-plugins\fresh-setup-mu-plugin.php`
|
||||
8. Visit `http://localhost:10004/` once. The plugin runs at `init` priority 50, configures everything, and self-deletes after success.
|
||||
9. Verify by hitting `http://localhost:10004/wp-admin` — login, then check that:
|
||||
- Theme : Asterion Bricks active (parent: Bricks)
|
||||
- Plugins : WPML active
|
||||
- Settings → Permalinks : Post name (`/%postname%/`)
|
||||
- Bricks → Settings → Builder access : Page + Post + case_study + scenario checked
|
||||
|
||||
Then activate the Bricks license (Bricks → License) and run the WPML setup wizard manually — those need your license keys and an interactive choice flow that's safer to do in admin.
|
||||
|
||||
## What's missing — manual follow-up after fresh setup
|
||||
|
||||
- Bricks license key activation (Bricks → License)
|
||||
- WPML setup wizard (WPML → Setup) : EN default + FR secondary, URL strategy = "Different languages in directories"
|
||||
- Bricks → Theme Styles : align colors with `tokens.css` (Brand Navy `#0B1F3A`, Brand Gold `#C9A45A`, etc.)
|
||||
- Build the Header and Footer Bricks Templates (per RESTART-PLAN.md Phase 4)
|
||||
125
tools/fresh-setup-mu-plugin.php
Normal file
125
tools/fresh-setup-mu-plugin.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: Asterion Fresh Setup (one-shot)
|
||||
* Description: Configures a brand-new LocalWP install for the Asterion VR project — sets siteurl/home, permalinks, activates Bricks child theme + WPML, configures Bricks postTypes. Self-deletes after success.
|
||||
* Version: 0.1.0
|
||||
*
|
||||
* USAGE
|
||||
* -----
|
||||
* After deleting the old LocalWP site and creating a new "Asterion 2026":
|
||||
* 1. Note the new site's HTTP port from LocalWP (likely 10004 again).
|
||||
* 2. Re-create the Junction so the child theme lives in the LocalWP install:
|
||||
* (run as admin from PowerShell)
|
||||
* New-Item -ItemType Junction `
|
||||
* -Path "<NEW_SITE_PATH>\app\public\wp-content\themes\asterion-bricks" `
|
||||
* -Target "C:\ASTERION\GIT\WP2026\wp-content\themes\asterion-bricks"
|
||||
* 3. Extract ThirdParty/bricks.X.Y.Z.zip into the LocalWP themes/ folder.
|
||||
* 4. Extract ThirdParty/sitepress-multilingual-cms.X.Y.Z.zip into plugins/.
|
||||
* 5. If the new port is NOT 10004, edit the AV_TARGET_HOME constant below.
|
||||
* 6. Copy this file to <NEW_SITE_PATH>\app\public\wp-content\mu-plugins\.
|
||||
* 7. Visit http://localhost:<port>/ once — the plugin runs and self-deletes.
|
||||
*
|
||||
* What it sets up
|
||||
* ---------------
|
||||
* - WP_HOME / WP_SITEURL options pointing at localhost:<port>
|
||||
* - Permalinks /%postname%/
|
||||
* - Activates Bricks parent + Asterion Bricks child theme (bricks-bricks-child)
|
||||
* - Activates WPML core
|
||||
* - Configures Bricks postTypes = ['page', 'post', 'case_study', 'scenario']
|
||||
* - Sets the WP timezone to Europe/Paris and locale to en_US (default)
|
||||
*
|
||||
* What it does NOT do (do these manually in WP admin)
|
||||
* ---------------------------------------------------
|
||||
* - Bricks license activation (Bricks → License → paste your key)
|
||||
* - WPML license + setup wizard (WPML → Setup → EN default + FR + directories)
|
||||
* - Bricks Theme Styles (Bricks → Theme Styles → align with tokens.css)
|
||||
* - Build of the Header / Footer / archive Bricks Templates
|
||||
*
|
||||
* @package AsterionBricks
|
||||
* @since 0.2.0
|
||||
*/
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
// Hardcode the target site URL. Adjust if LocalWP allocated a different port.
|
||||
define('AV_TARGET_HOME', 'http://localhost:10004');
|
||||
|
||||
add_action('init', function () {
|
||||
|
||||
if (get_option('av_fresh_setup_done') === '1') {
|
||||
$self = __FILE__;
|
||||
add_action('shutdown', function () use ($self) {
|
||||
if (file_exists($self)) {
|
||||
@unlink($self);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
$log = [];
|
||||
|
||||
// 1. Site URL + home (avoids the localhost:port → / 301 cache trap)
|
||||
update_option('siteurl', AV_TARGET_HOME);
|
||||
update_option('home', AV_TARGET_HOME);
|
||||
$log[] = "Set siteurl/home to " . AV_TARGET_HOME;
|
||||
|
||||
// 2. Pretty permalinks (required for /customers/ /scenarios/ slugs and WPML)
|
||||
if (get_option('permalink_structure') !== '/%postname%/') {
|
||||
update_option('permalink_structure', '/%postname%/');
|
||||
$log[] = "Set permalink_structure to /%postname%/";
|
||||
}
|
||||
|
||||
// 3. Timezone + WP locale defaults
|
||||
update_option('timezone_string', 'Europe/Paris');
|
||||
if (get_locale() !== 'en_US') {
|
||||
update_option('WPLANG', 'en_US');
|
||||
}
|
||||
|
||||
// 4. Activate Bricks child theme (its parent Bricks must be present)
|
||||
$themes = wp_get_themes();
|
||||
if (isset($themes['bricks']) && isset($themes['asterion-bricks'])) {
|
||||
if (get_option('stylesheet') !== 'asterion-bricks') {
|
||||
switch_theme('asterion-bricks');
|
||||
$log[] = "Switched theme to asterion-bricks (parent: bricks)";
|
||||
}
|
||||
} else {
|
||||
$missing = [];
|
||||
if (! isset($themes['bricks'])) $missing[] = 'bricks (parent)';
|
||||
if (! isset($themes['asterion-bricks'])) $missing[] = 'asterion-bricks (child junction)';
|
||||
$log[] = "Theme NOT switched. Missing: " . implode(', ', $missing);
|
||||
}
|
||||
|
||||
// 5. Activate WPML core
|
||||
if (! function_exists('is_plugin_active')) {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
}
|
||||
$wpml_main = 'sitepress-multilingual-cms/sitepress.php';
|
||||
if (file_exists(WP_PLUGIN_DIR . '/' . $wpml_main)) {
|
||||
if (! is_plugin_active($wpml_main)) {
|
||||
$result = activate_plugin($wpml_main, '', false, true);
|
||||
$log[] = is_wp_error($result)
|
||||
? 'WPML activation FAILED: ' . $result->get_error_message()
|
||||
: 'WPML activated';
|
||||
} else {
|
||||
$log[] = 'WPML already active';
|
||||
}
|
||||
} else {
|
||||
$log[] = "WPML not found at plugins/{$wpml_main}";
|
||||
}
|
||||
|
||||
// 6. Bricks: enable Page/Post/CPT in Builder access > postTypes
|
||||
if (defined('BRICKS_DB_GLOBAL_SETTINGS')) {
|
||||
$settings = get_option(BRICKS_DB_GLOBAL_SETTINGS, []);
|
||||
$settings['postTypes'] = ['page', 'post', 'case_study', 'scenario'];
|
||||
update_option(BRICKS_DB_GLOBAL_SETTINGS, $settings);
|
||||
$log[] = "Bricks postTypes set to page/post/case_study/scenario";
|
||||
} else {
|
||||
$log[] = "Bricks not loaded yet — re-run by visiting the site once Bricks is active";
|
||||
}
|
||||
|
||||
// 7. Flush rewrite rules so the new permalink structure takes effect
|
||||
flush_rewrite_rules();
|
||||
|
||||
update_option('av_fresh_setup_done', '1', false);
|
||||
update_option('av_fresh_setup_log', $log, false);
|
||||
|
||||
}, 50);
|
||||
Reference in New Issue
Block a user