@@ -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- / \/ \/ O n l y e n q u e u e o n o u r p a g e \n \s + i f \( ! i s s e t \( \$ _ G E T \[ ' p a g e ' \] \) \| \| ' ( [ ^ ' ] + ) ' ! = = \$ _ G E T \[ ' p a g e ' \] \) { \/ \/ p h p c s : i g n o r e W o r d P r e s s \. S e c u r i t y \. N o n c e V e r i f i c a t i o n \. R e c o m m e n d e d \n \s + r e t u r n ; \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