@@ -253,8 +253,6 @@ function generateScriptModulesPackages() {
253253 if ( match ) {
254254 // Parse PHP array to JavaScript object
255255 const assetData = parsePHPArray ( match [ 1 ] ) ;
256-
257- // Create entries for both minified and non-minified versions
258256 assetsMin [ jsPathMin ] = assetData ;
259257 assetsRegular [ jsPathRegular ] = assetData ;
260258 }
@@ -680,52 +678,18 @@ function parsePHPArray( phpArrayContent ) {
680678function transformPHPContent ( content , srcPath , destPath ) {
681679 let transformed = content ;
682680
683- // Replace plugins_url() with includes_url()
684- // Handles patterns like: plugins_url( 'build/...' . $var, dirname( __FILE__ ) )
685- transformed = transformed . replace (
686- / p l u g i n s _ u r l \( \s * ( [ ^ , ] + ) , \s * (?: d i r n a m e \( \s * _ _ F I L E _ _ \s * \) | _ _ F I L E _ _ ) \s * \) / g,
687- ( match , firstArg ) => {
688- return `includes_url( ${ firstArg . trim ( ) } )` ;
689- }
690- ) ;
691-
692- // Replace plugin_dir_path( __FILE__ ) with ABSPATH . WPINC . '/build/'
693- transformed = transformed . replace (
694- / p l u g i n _ d i r _ p a t h \( \s * _ _ F I L E _ _ \s * \) / g,
695- "ABSPATH . WPINC . '/build/'"
696- ) ;
697-
698- // Replace dirname( __FILE__ ) patterns in path construction
681+ // Fix boot module asset file path for Core's different directory structure
682+ // FROM: __DIR__ . '/../../modules/boot/index.min.asset.php'
683+ // TO: ABSPATH . WPINC . '/js/dist/script-modules/boot/index.min.asset.php'
684+ // This is needed because Core copies modules to a different location than the plugin structure
699685 transformed = transformed . replace (
700- / d i r n a m e \( \s * _ _ F I L E _ _ \s * \) / g,
701- "ABSPATH . WPINC . '/build'"
702- ) ;
703-
704- // Replace __DIR__ with ABSPATH . WPINC . '/build'
705- transformed = transformed . replace (
706- / _ _ D I R _ _ \s * \. \s * [ ' " ] \/ \. \. \/ ( .* ?) [ ' " ] / g,
707- ( match , relativePath ) => {
708- return `ABSPATH . WPINC . '/build/${ relativePath } '` ;
709- }
686+ / _ _ D I R _ _ \s * \. \s * [ ' " ] \/ \. \. \/ \. \. \/ m o d u l e s \/ b o o t \/ i n d e x \. m i n \. a s s e t \. p h p [ ' " ] / g,
687+ "ABSPATH . WPINC . '/js/dist/script-modules/boot/index.min.asset.php'"
710688 ) ;
711689
712690 // Special transformations for page-wp-admin.php files
713691 if ( destPath . includes ( 'page-wp-admin.php' ) ) {
714- // Fix boot module asset file path
715- // FROM: ABSPATH . WPINC . '/build/' . '../../modules/boot/index.min.asset.php'
716- // TO: ABSPATH . WPINC . '/js/dist/script-modules/boot/index.min.asset.php'
717- transformed = transformed . replace (
718- / A B S P A T H \s * \. \s * W P I N C \s * \. \s * [ ' " ] \/ b u i l d \/ [ ' " ] \s * \. \s * [ ' " ] \. \. \/ \. \. \/ m o d u l e s \/ b o o t \/ i n d e x \. m i n \. a s s e t \. p h p [ ' " ] / g,
719- "ABSPATH . WPINC . '/js/dist/script-modules/boot/index.min.asset.php'"
720- ) ;
721692
722- // Fix loader.js path - replace plugin_dir_url with data URI for empty module
723- // FROM: plugin_dir_url( __FILE__ ) . 'loader.js'
724- // TO: 'data:text/javascript,' (empty module for dependency registration only)
725- transformed = transformed . replace (
726- / p l u g i n _ d i r _ u r l \( \s * _ _ F I L E _ _ \s * \) \s * \. \s * [ ' " ] l o a d e r \. j s [ ' " ] / g,
727- "'data:text/javascript,'"
728- ) ;
729693
730694 // Fix enqueue condition to also work for direct page files (e.g., fonts.php)
731695 // This allows the page to work both via menu (admin.php?page=X) and direct file (X.php)
0 commit comments