Skip to content

Commit ce9e365

Browse files
committed
More copy simplifications
1 parent 8b113a3 commit ce9e365

File tree

2 files changed

+6
-40
lines changed

2 files changed

+6
-40
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"url": "https://develop.svn.wordpress.org/trunk"
88
},
99
"gutenberg": {
10-
"ref": "c5a9e02338f37d8d7c80570aaaaff261e3f9d198"
10+
"ref": "b79bbe25a1b00ce640bfab363f182c678181082f"
1111
},
1212
"engines": {
1313
"node": ">=20.10.0",

tools/gutenberg/copy-gutenberg-build.js

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ const COPY_CONFIG = {
4141
destination: 'build',
4242
files: [ 'routes.php', 'pages.php' ],
4343
directories: [ 'pages', 'routes' ],
44-
transform: true, // Apply PHP transformations
4544
},
4645

4746
// JavaScript packages (to wp-includes/js/dist/)
@@ -104,7 +103,6 @@ const COPY_CONFIG = {
104103
'class-wp-block-parser-frame.php',
105104
],
106105
destination: '', // Root of wp-includes
107-
transform: false,
108106
},
109107
],
110108
},
@@ -115,7 +113,6 @@ const COPY_CONFIG = {
115113
{ from: 'theme.json', to: 'theme.json' },
116114
{ from: 'theme-i18n.json', to: 'theme-i18n.json' },
117115
],
118-
transform: true,
119116
},
120117
};
121118

@@ -268,16 +265,15 @@ function copyBlockAssets( config ) {
268265
}
269266
}
270267

271-
// 3. Copy and transform PHP from packages
268+
// 3. Copy PHP from packages
272269
const blockPhpSrc = path.join( phpSrc, blockName, 'index.php' );
273270
if ( fs.existsSync( blockPhpSrc ) ) {
274271
const phpDest = path.join(
275272
wpIncludesDir,
276273
config.destination,
277274
`${ blockName }.php`
278275
);
279-
let content = fs.readFileSync( blockPhpSrc, 'utf8' );
280-
content = transformPHPContent( content, blockPhpSrc, phpDest );
276+
const content = fs.readFileSync( blockPhpSrc, 'utf8' );
281277
fs.writeFileSync( phpDest, content );
282278
}
283279
}
@@ -818,11 +814,9 @@ function parsePHPArray( phpArrayContent ) {
818814
* Transform PHP file contents to work in Core.
819815
*
820816
* @param {string} content - File content.
821-
* @param {string} srcPath - Source file path.
822-
* @param {string} destPath - Destination file path.
823817
* @return {string} Transformed content.
824818
*/
825-
function transformPHPContent( content, srcPath, destPath ) {
819+
function transformPHPContent( content ) {
826820
let transformed = content;
827821

828822
// Fix boot module asset file path for Core's different directory structure
@@ -834,26 +828,6 @@ function transformPHPContent( content, srcPath, destPath ) {
834828
"ABSPATH . WPINC . '/js/dist/script-modules/boot/index.min.asset.php'"
835829
);
836830

837-
// Special transformations for page-wp-admin.php files
838-
if ( destPath.includes( 'page-wp-admin.php' ) ) {
839-
// Fix enqueue condition to also work for direct page files (e.g., fonts.php)
840-
// This allows the page to work both via menu (admin.php?page=X) and direct file (X.php)
841-
transformed = transformed.replace(
842-
/\/\/ Only enqueue on our page\n\s+if \( ! isset\( \$_GET\['page'\] \) \|\| '([^']+)' !== \$_GET\['page'\] \) { \/\/ phpcs:ignore WordPress\.Security\.NonceVerification\.Recommended\n\s+return;\n\s+}/,
843-
( match, pageName ) => {
844-
// Extract the base name (e.g., 'font-library' from 'font-library-wp-admin')
845-
const baseName = pageName.replace( '-wp-admin', '' );
846-
return `// Only enqueue on our page (either ${ baseName }.php or the menu page)
847-
$is_menu_page = isset( $_GET['page'] ) && '${ pageName }' === $_GET['page']; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
848-
$is_direct_page = '${ baseName }.php' === $hook_suffix;
849-
850-
if ( ! $is_menu_page && ! $is_direct_page ) {
851-
return;
852-
}`;
853-
}
854-
);
855-
}
856-
857831
return transformed;
858832
}
859833

@@ -886,9 +860,7 @@ async function main() {
886860
if ( fs.existsSync( src ) ) {
887861
fs.mkdirSync( path.dirname( dest ), { recursive: true } );
888862
let content = fs.readFileSync( src, 'utf8' );
889-
if ( phpConfig.transform ) {
890-
content = transformPHPContent( content, src, dest );
891-
}
863+
content = transformPHPContent( content );
892864
fs.writeFileSync( dest, content );
893865
console.log( ` ✅ ${ file }` );
894866
} else {
@@ -905,8 +877,7 @@ async function main() {
905877

906878
if ( fs.existsSync( src ) ) {
907879
console.log( ` 📁 Copying ${ dir }/...` );
908-
const transform = phpConfig.transform ? transformPHPContent : null;
909-
copyDirectory( src, dest, transform );
880+
copyDirectory( src, dest, transformPHPContent );
910881
console.log( ` ✅ ${ dir }/ copied` );
911882
}
912883
}
@@ -1096,11 +1067,6 @@ async function main() {
10961067
if ( fs.existsSync( src ) ) {
10971068
fs.mkdirSync( path.dirname( dest ), { recursive: true } );
10981069
let content = fs.readFileSync( src, 'utf8' );
1099-
1100-
if ( fileGroup.transform ) {
1101-
content = transformPHPContent( content, src, dest );
1102-
}
1103-
11041070
fs.writeFileSync( dest, content );
11051071
}
11061072
}

0 commit comments

Comments
 (0)