From 88e994066bb5c65c676df7059ae90290e7dfeced Mon Sep 17 00:00:00 2001 From: Sukhendu Sekhar Guria Date: Wed, 20 May 2026 13:23:13 +0530 Subject: [PATCH 1/2] Build/Test Tools: Display Gutenberg commit hash in admin footer and At a Glance widget --- src/wp-admin/includes/update.php | 39 ++++++++++++++++++++++++-- src/wp-includes/version.php | 11 ++++++++ tools/gutenberg/copy.js | 47 ++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/includes/update.php b/src/wp-admin/includes/update.php index f5aeea835bd12..2a0722da88ad8 100644 --- a/src/wp-admin/includes/update.php +++ b/src/wp-admin/includes/update.php @@ -267,12 +267,28 @@ function core_update_footer( $msg = '' ) { $is_development_version = preg_match( '/alpha|beta|RC/', wp_get_wp_version() ); if ( $is_development_version ) { - return sprintf( + $footer = sprintf( /* translators: 1: WordPress version number, 2: URL to WordPress Updates screen. */ __( 'You are using a development version (%1$s). Cool! Please stay updated.' ), get_bloginfo( 'version', 'display' ), network_admin_url( 'update-core.php' ) ); + + global $wp_gutenberg_hash; + + if ( $wp_gutenberg_hash + && in_array( wp_get_environment_type(), array( 'local', 'development' ), true ) + ) { + $short_hash = substr( $wp_gutenberg_hash, 0, 7 ); + $footer .= ' | ' . sprintf( + /* translators: 1: Gutenberg commit URL, 2: Short commit hash. */ + __( 'Gutenberg %2$s' ), + esc_url( 'https://github.com/WordPress/gutenberg/commit/' . $wp_gutenberg_hash ), + esc_html( $short_hash ) + ); + } + + return $footer; } switch ( $cur->response ) { @@ -391,7 +407,26 @@ function update_right_now_message() { */ $content = apply_filters( 'update_right_now_text', $content ); - $msg .= sprintf( '' . $content . '', get_bloginfo( 'version', 'display' ), $theme_name ); + global $wp_gutenberg_hash; + + if ( $wp_gutenberg_hash + && preg_match( '/alpha|beta|RC/', wp_get_wp_version() ) + && in_array( wp_get_environment_type(), array( 'local', 'development' ), true ) + ) { + $short_hash = substr( $wp_gutenberg_hash, 0, 7 ); + $version_string = sprintf( + /* translators: 1: WordPress version number, 2: URL to Gutenberg commit, 3: Short commit hash. */ + __( '%1$s (built with %3$s)' ), + get_bloginfo( 'version', 'display' ), + esc_url( 'https://github.com/WordPress/gutenberg/commit/' . $wp_gutenberg_hash ), + esc_html( $short_hash ) + ); + $content = sprintf( $content, $version_string, $theme_name ); + } else { + $content = sprintf( $content, get_bloginfo( 'version', 'display' ), $theme_name ); + } + + $msg .= '' . $content . ''; echo "

$msg

"; } diff --git a/src/wp-includes/version.php b/src/wp-includes/version.php index 934e5d0bb5369..0b25b1418fce4 100644 --- a/src/wp-includes/version.php +++ b/src/wp-includes/version.php @@ -55,3 +55,14 @@ * @global string $required_mysql_version */ $required_mysql_version = '5.5.5'; + +/** + * Holds the Gutenberg commit hash used to build the included assets. + * + * This value is set during the build process and corresponds to the + * Gutenberg repository commit from which the bundled assets were generated. + * + * @since 7.1.0 + * @global string $wp_gutenberg_hash + */ +$wp_gutenberg_hash = ''; diff --git a/tools/gutenberg/copy.js b/tools/gutenberg/copy.js index b3c4b7f9aa9ba..941a54c60b6d3 100644 --- a/tools/gutenberg/copy.js +++ b/tools/gutenberg/copy.js @@ -519,6 +519,49 @@ function generateBlocksJson() { ); } +/** + * Update the $wp_gutenberg_hash value in version.php. + * Reads the hash from gutenberg/.gutenberg-hash (the actual built version) + * and writes it into the version file so it is available at runtime. + */ +function updateVersionFile() { + const hashFilePath = path.join( gutenbergDir, '.gutenberg-hash' ); + const versionFile = path.join( rootDir, buildTarget, 'wp-includes/version.php' ); + + if ( ! fs.existsSync( hashFilePath ) ) { + console.error( ' ❌ gutenberg/.gutenberg-hash not found' ); + process.exit( 1 ); + } + + const installedHash = fs.readFileSync( hashFilePath, 'utf8' ).trim(); + + if ( ! /^[0-9a-f]{40}$/.test( installedHash ) ) { + console.error( ' ❌ Invalid SHA format in .gutenberg-hash' ); + process.exit( 1 ); + } + + if ( ! fs.existsSync( versionFile ) ) { + console.log( ' ⚠️ version.php not found, skipping hash update' ); + return; + } + + const content = fs.readFileSync( versionFile, 'utf8' ); + const pattern = /\$wp_gutenberg_hash = '[^']*';/; + + if ( ! pattern.test( content ) ) { + console.error( ' ❌ $wp_gutenberg_hash pattern not found in version.php' ); + process.exit( 1 ); + } + + const updated = content.replace( + pattern, + `$wp_gutenberg_hash = '${ installedHash }';` + ); + + fs.writeFileSync( versionFile, updated ); + console.log( ` ✅ Set $wp_gutenberg_hash to ${ installedHash.substring( 0, 7 ) }` ); +} + /** * Main execution function. */ @@ -637,6 +680,10 @@ async function main() { console.log( '\n📦 Generating blocks-json.php...' ); generateBlocksJson(); + // 7. Update $wp_gutenberg_hash in version.php. + console.log( '\n📦 Updating Gutenberg hash in version.php...' ); + updateVersionFile(); + console.log( '\n✅ Copy complete!' ); } From 6aa493e06cecb943a616b6b1a3d1d636f33cf887 Mon Sep 17 00:00:00 2001 From: "wordpress-develop-pr-bot[bot]" <1178653+wordpress-develop-pr-bot[bot]@users.noreply.github.com> Date: Wed, 20 May 2026 07:58:06 +0000 Subject: [PATCH 2/2] Automation: Updating built files with changes. --- src/wp-includes/version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/version.php b/src/wp-includes/version.php index 0b25b1418fce4..d1144bd9cf4ab 100644 --- a/src/wp-includes/version.php +++ b/src/wp-includes/version.php @@ -65,4 +65,4 @@ * @since 7.1.0 * @global string $wp_gutenberg_hash */ -$wp_gutenberg_hash = ''; +$wp_gutenberg_hash = 'a2a354cf35e5b69c3330d6c1cfd42d8dc2efb9fd';