From 59ea0215db8f7496dd97a94013bee597cf7315c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Mon, 3 Aug 2026 12:23:15 +0100 Subject: [PATCH 01/12] add package provenance module to debug helper admin-bar badge + floating panel showing which runtime serves each WordPress package (core, Gutenberg plugin, wp-build polyfills, app) --- .../changelog/add-package-provenance-helper | 4 + .../class-package-provenance-helper.php | 233 ++++++++++++++++++ projects/plugins/debug-helper/plugin.php | 5 + 3 files changed, 242 insertions(+) create mode 100644 projects/plugins/debug-helper/changelog/add-package-provenance-helper create mode 100644 projects/plugins/debug-helper/modules/class-package-provenance-helper.php diff --git a/projects/plugins/debug-helper/changelog/add-package-provenance-helper b/projects/plugins/debug-helper/changelog/add-package-provenance-helper new file mode 100644 index 000000000000..60c6905cc67b --- /dev/null +++ b/projects/plugins/debug-helper/changelog/add-package-provenance-helper @@ -0,0 +1,4 @@ +Significance: minor +Type: added + +Package Provenance: Add a module showing which runtime serves each WordPress package on the current screen. diff --git a/projects/plugins/debug-helper/modules/class-package-provenance-helper.php b/projects/plugins/debug-helper/modules/class-package-provenance-helper.php new file mode 100644 index 000000000000..9a8a86327345 --- /dev/null +++ b/projects/plugins/debug-helper/modules/class-package-provenance-helper.php @@ -0,0 +1,233 @@ +gutenberg_version(); + $wp_admin_bar->add_menu( + array( + 'id' => 'package-provenance', + 'title' => sprintf( + '📦 WP %s · GB %s', + esc_html( $GLOBALS['wp_version'] ?? '?' ), + esc_html( $gutenberg ?? 'off' ) + ), + 'href' => '#', + 'parent' => 'top-secondary', + ) + ); + } + + /** + * Collects registered classic scripts and script modules with their sources. + * + * Runs late in the request so it sees everything the current screen + * registered, including conditional registrations like the wp-build + * polyfills (which only register on dashboard requests). + * + * @return array{wp: string, gutenberg: string|null, scripts: array, modules: array} + */ + private function collect() { + $scripts = array(); + foreach ( wp_scripts()->registered as $handle => $dependency ) { + if ( 0 !== strpos( $handle, 'wp-' ) || ! is_string( $dependency->src ) || '' === $dependency->src ) { + continue; + } + $scripts[ $handle ] = array( + 'src' => $dependency->src, + 'ver' => (string) $dependency->ver, + 'printed' => in_array( $handle, wp_scripts()->done, true ), + ); + } + ksort( $scripts ); + + $modules = array(); + if ( function_exists( 'wp_script_modules' ) ) { + try { + $property = new \ReflectionProperty( wp_script_modules(), 'registered' ); + if ( PHP_VERSION_ID < 80100 ) { + $property->setAccessible( true ); + } + foreach ( (array) $property->getValue( wp_script_modules() ) as $id => $module ) { + if ( 0 !== strpos( (string) $id, '@' ) ) { + continue; + } + $modules[ $id ] = array( + 'src' => (string) ( $module['src'] ?? '' ), + 'ver' => (string) ( $module['version'] ?? '' ), + ); + } + } catch ( \ReflectionException $e ) { + // Private property moved; the client-side import map still covers modules. + $modules = array(); + } + } + ksort( $modules ); + + return array( + 'wp' => (string) ( $GLOBALS['wp_version'] ?? '' ), + 'gutenberg' => $this->gutenberg_version(), + 'scripts' => $scripts, + 'modules' => $modules, + ); + } + + /** + * Prints the floating panel and its data. + */ + public function render() { + $data = $this->collect(); + ?> + + + + + 'Broken XML-RPC', 'description' => 'Break XML-RPC API any way you want.', ), + 'package-provenance' => array( + 'file' => 'class-package-provenance-helper.php', + 'name' => 'Package Provenance', + 'description' => 'Admin-bar badge with WP + Gutenberg versions and a floating panel showing which runtime (core, Gutenberg, wp-build polyfills, app) serves each WordPress package on the current screen.', + ), ); require_once __DIR__ . '/class-admin.php'; From a748d89b535da459727786e4e897a648dedbf86d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Mon, 3 Aug 2026 13:48:49 +0100 Subject: [PATCH 02/12] raise provenance panel label contrast dim rows by text color instead of opacity so provider badges stay legible; brighten the badge palette one step --- .../modules/class-package-provenance-helper.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/projects/plugins/debug-helper/modules/class-package-provenance-helper.php b/projects/plugins/debug-helper/modules/class-package-provenance-helper.php index 9a8a86327345..57bd06452213 100644 --- a/projects/plugins/debug-helper/modules/class-package-provenance-helper.php +++ b/projects/plugins/debug-helper/modules/class-package-provenance-helper.php @@ -139,13 +139,15 @@ public function render() { padding: 1px 8px 1px 0; text-align: start; white-space: nowrap; vertical-align: top; } #package-provenance-body th { color: #9cdcfe; position: sticky; inset-block-start: 0; background: #1e1e1e; } - .pkg-prov { padding: 0 5px; border-radius: 3px; color: #111; font-weight: 700; } - .pkg-prov-core { background: #569cd6; } - .pkg-prov-gutenberg { background: #c586c0; } - .pkg-prov-polyfill { background: #ce9178; } - .pkg-prov-app { background: #6a9955; } - .pkg-prov-other { background: #808080; } - .pkg-dim { opacity: .45; } + .pkg-prov { padding: 0 5px; border-radius: 3px; color: #0a0a0a; font-weight: 700; } + .pkg-prov-core { background: #6ab0f3; } + .pkg-prov-gutenberg { background: #d49bd0; } + .pkg-prov-polyfill { background: #e0a184; } + .pkg-prov-app { background: #7fb069; } + .pkg-prov-other { background: #9a9a9a; } + /* Dim by text color, not row opacity, so provider labels stay legible. */ + .pkg-dim td { color: #8a8a8a; } + .pkg-dim .pkg-prov { filter: saturate( .55 ) brightness( .82 ); } #package-provenance-note { color: #808080; margin-block-start: 6px; white-space: normal; }