Skip to content
Corex

PluginRealpathRegistrar

Corex\Blocks\PluginRealpathRegistrar · class · Blocks layer

Spec 040, extended: WordPress only learns a junctioned/symlinked plugin’s real on-disk location when it activates that plugin itself (via wp_register_plugin_realpath() in wp-settings, recorded in the $wp_plugin_paths global). Corex add-ons loaded through Boot’s provider list — not WordPress’s active_plugins — are never registered, so once register_block_type_from_metadata() realpath()-resolves a block’s block.json back to the monorepo addons/ path, plugin_basename() cannot map it under WP_PLUGIN_DIR and plugins_url() emits a broken …/plugins/C:/wamp64/… asset URL. This registrar replays that mapping for every junctioned mount at boot, so block (and other) asset URLs resolve correctly for every add-on — matching the WordPress-activated ones. The path arithmetic is pure (headless-testable); the single wp_register_plugin_realpath() call is the WordPress boundary.

Register the realpath mapping with WordPress for each junctioned/symlinked mount, so plugin_basename() resolves their assets back under WP_PLUGIN_DIR. A no-op when the WordPress function is absent (headless/tests).

pluginFiles(array $mounts, string $pluginsDir): array

Section titled “pluginFiles(array $mounts, string $pluginsDir): array”

The candidate main-plugin file (<entry>/<entry>.php, the Corex add-on convention) for each mount whose real target differs from its WP_PLUGIN_DIR location — i.e. it is a junction/symlink WordPress would otherwise not know about. A mount that already lives under the plugins dir is skipped (WordPress resolves it natively).