doxa-maps/deployment/wordpress/doxa-maps-embed/doxa-maps-embed.php
doxa-maps-88655c70 9dc4dda8cf
Some checks are pending
build-gate / build (push) Waiting to run
consolidate docs into documentation/ and deployment shells into deployment/
Driver 2026-09-21: 'a folder called deployment which will store the capacitor
folder, wordpress folder and tauri folder', and 'a folder called documentation
to store the contributing folder so docs are in one place'.

docs/ + contributing/ + CONTRIBUTING.md -> documentation/ (three doc homes into
one). capacitor/ + wordpress/ + src-tauri/ -> deployment/.

The public/ -> dist/ rename the Driver asked about is NOT here: after seeing the
measured blast radius (855 tracked files, 54 source refs, and public/ is the
served web-root four consumers point at) the Driver withdrew it - 'keep the
public folder the same'.

Path references were rewritten mechanically (258 across 87 files), but three
classes needed hand fixes because a prefix regex cannot see them:
  - join(ROOT,'docs',...) in 10 internal scripts - a quoted SEGMENT, not a prefix
  - tauri frontendDist '../public' -> '../../public', since src-tauri is now one
    level deeper; check:tauri caught this exactly as the card predicted
  - the WordPress contract test's dirname(__DIR__,2) -> 3, same reason

Also reverted one over-reach: the rewrite renamed a FINDING-CATEGORY label
'docs' in public-hygiene-check.mjs, which is a rule name in its own header, not
a path.

Verified: full build ALL GUARDS PASS, SRI consistent; check:tauri, check:mobile
(cap sync + webDir OK), check:wp-embed, quoted-scripts, capability-citations,
capability-exemplars, library-index, public-hygiene, parse and drop all pass.
2026-09-21 23:23:23 +00:00

61 lines
2.6 KiB
PHP

<?php
/**
* Plugin Name: Doxa Maps Embed
* Plugin URI: https://doxa.life/
* Description: Embed portable Doxa Maps bundles (custom elements) on any post or page via the [doxa_map] shortcode or a Gutenberg block. Loads the bundle from a public catalog (CDN) — nothing is bundled into WordPress (portable-consumer pattern).
* Version: 0.1.0
* Requires at least: 5.8
* Requires PHP: 7.4
* Author: Doxa Maps
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: doxa-maps-embed
*
* DEPLOY METHOD 4 (WordPress) for the doxa-maps plugin studio.
*
* This plugin is a thin WRAPPER around the portable doxa-maps custom elements. It does NOT
* ship a copy of any bundle: it references the PUBLIC catalog (the served built tree +
* manifest.json) by URL and emits the manifest's `embed.script` snippet — a <script src>
* with SRI + a <element profile-config='…'> tag — exactly as documented in
* docs/architecture/embeddability.md ("The manifest — embed snippets as data").
*
* The one job of a WordPress wrapper is to reproduce that snippet from PHP against a
* configurable catalog base, escape everything on the way out, and register the bundle
* script through WordPress's own dependency graph (so SRI + crossorigin survive and the
* script loads once even if a page has several maps).
*/
// No direct file access.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
define( 'DOXA_MAPS_EMBED_VERSION', '0.1.0' );
define( 'DOXA_MAPS_EMBED_FILE', __FILE__ );
define( 'DOXA_MAPS_EMBED_DIR', plugin_dir_path( __FILE__ ) );
/**
* The default public catalog base — the served root of the built doxa-maps tree, i.e. the
* directory that contains manifest.json and every <bundle>/<bundle>.js. It maps 1:1 to the
* bundle's own `window.MAP_EMBED_BASE_URL` / embedBase.js "tree root" concept.
*
* Override per-site in Settings → Doxa Maps, or per-embed with the shortcode `base=""` attr.
* This illustrative default matches the one used in library/utils/embedBase.js.
*/
if ( ! defined( 'DOXA_MAPS_EMBED_DEFAULT_BASE' ) ) {
define( 'DOXA_MAPS_EMBED_DEFAULT_BASE', 'https://doxa.life/js/doxa-maps' );
}
require_once DOXA_MAPS_EMBED_DIR . 'includes/class-doxa-maps-embed.php';
require_once DOXA_MAPS_EMBED_DIR . 'includes/class-doxa-maps-embed-settings.php';
/**
* Boot the singleton on plugins_loaded.
*/
function doxa_maps_embed_boot() {
Doxa_Maps_Embed::instance();
if ( is_admin() ) {
Doxa_Maps_Embed_Settings::instance();
}
}
add_action( 'plugins_loaded', 'doxa_maps_embed_boot' );