Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions src/wp-admin/includes/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href="%2$s">stay updated</a>.' ),
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 <a href="%1$s">%2$s</a>' ),
esc_url( 'https://github.com/WordPress/gutenberg/commit/' . $wp_gutenberg_hash ),
esc_html( $short_hash )
);
}

return $footer;
}

switch ( $cur->response ) {
Expand Down Expand Up @@ -391,7 +407,26 @@ function update_right_now_message() {
*/
$content = apply_filters( 'update_right_now_text', $content );

$msg .= sprintf( '<span id="wp-version">' . $content . '</span>', 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 <a href="%2$s">%3$s</a>)' ),
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 .= '<span id="wp-version">' . $content . '</span>';

echo "<p id='wp-version-message'>$msg</p>";
}
Expand Down
11 changes: 11 additions & 0 deletions src/wp-includes/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 'a2a354cf35e5b69c3330d6c1cfd42d8dc2efb9fd';
47 changes: 47 additions & 0 deletions tools/gutenberg/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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!' );
}

Expand Down
Loading