Make WordPress Core

Changeset 61504


Ignore:
Timestamp:
01/20/2026 11:01:11 PM (7 weeks ago)
Author:
dmsnell
Message:

Build: Restore block parser in Core.

The work in [61438] for Core-64393 removed the block parser classes from Core, which caused numerous scripts to fail because they were missing. Conditional checks were added in [61492] which left WordPress in an inoperable state.

This patch restores the block parser in Core, in preparation for work to remove it from Gutenberg (in a separate patch).

Ironically, the files were removed because the new build was copying them over from Gutenberg and the intent was to avoid having two sources of truth, but this was previously the existing mechanism, so having done nothing to the parser files would have left the status quo. This patch removes the problems originally created by removing the files. They will not be copied from Gutenberg any more and the only source of truth will be Core.

Until removed from Gutenberg, because of the build changes, any changes made on the Gutenberg side will be lost unless manually copied over.

Developed in: https://github.com/WordPress/wordpress-develop/pull/10761
Discussed in: https://core.trac.wordpress.org/ticket/64521

Follow-up to [61438], [61492].

Props dmsnell, mcsf, mukesh27, youknowriad.
Fixes #64521.

Location:
trunk
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/.gitignore

    r61492 r61504  
    3939!/src/wp-includes/blocks/index.php
    4040/src/wp-includes/build
    41 /src/wp-includes/class-wp-block-parser.php
    42 /src/wp-includes/class-wp-block-parser-block.php
    43 /src/wp-includes/class-wp-block-parser-frame.php
    4441/src/wp-includes/theme.json
    4542/packagehash.txt
  • trunk/src/wp-includes/blocks.php

    r61492 r61504  
    24222422    $parser_class = apply_filters( 'block_parser_class', 'WP_Block_Parser' );
    24232423
    2424     if ( ! class_exists( $parser_class ) ) {
    2425         return array();
    2426     }
    2427 
    24282424    $parser = new $parser_class();
    24292425    return $parser->parse( $content );
  • trunk/src/wp-includes/formatting.php

    r61492 r61504  
    52285228 */
    52295229function wp_pre_kses_block_attributes( $content, $allowed_html, $allowed_protocols ) {
    5230     // If the block parser isn't available, skip block attribute filtering.
    5231     if ( ! class_exists( 'WP_Block_Parser' ) ) {
    5232         return $content;
    5233     }
    5234 
    52355230    /*
    52365231     * `filter_block_content` is expected to call `wp_kses`. Temporarily remove
  • trunk/src/wp-settings.php

    r61492 r61504  
    378378require ABSPATH . WPINC . '/class-wp-block-list.php';
    379379require ABSPATH . WPINC . '/class-wp-block-metadata-registry.php';
    380 if ( file_exists( ABSPATH . WPINC . '/class-wp-block-parser-block.php' ) ) {
    381     require ABSPATH . WPINC . '/class-wp-block-parser-block.php';
    382 }
    383 if ( file_exists( ABSPATH . WPINC . '/class-wp-block-parser-frame.php' ) ) {
    384     require ABSPATH . WPINC . '/class-wp-block-parser-frame.php';
    385 }
    386 if ( file_exists( ABSPATH . WPINC . '/class-wp-block-parser.php' ) ) {
    387     require ABSPATH . WPINC . '/class-wp-block-parser.php';
    388 }
     380require ABSPATH . WPINC . '/class-wp-block-parser-block.php';
     381require ABSPATH . WPINC . '/class-wp-block-parser-frame.php';
     382require ABSPATH . WPINC . '/class-wp-block-parser.php';
    389383require ABSPATH . WPINC . '/class-wp-classic-to-block-menu-converter.php';
    390384require ABSPATH . WPINC . '/class-wp-navigation-fallback.php';
  • trunk/tools/gutenberg/copy-gutenberg-build.js

    r61492 r61504  
    8888                styles: 'styles/widgets',
    8989                php: 'widgets/src/blocks',
    90             },
    91         ],
    92     },
    93 
    94     // PHP source files (non-block files, copied from packages)
    95     phpSource: {
    96         files: [
    97             {
    98                 // Block parser classes
    99                 package: 'block-serialization-default-parser',
    100                 files: [
    101                     'class-wp-block-parser.php',
    102                     'class-wp-block-parser-block.php',
    103                     'class-wp-block-parser-frame.php',
    104                 ],
    105                 destination: '', // Root of wp-includes
    10690            },
    10791        ],
     
    10291013    copyBlockAssets( COPY_CONFIG.blocks );
    10301014
    1031     // 6. Copy non-block PHP source files (from packages)
    1032     console.log( '\n📦 Copying non-block PHP files...' );
    1033     const phpSourceConfig = COPY_CONFIG.phpSource;
    1034 
    1035     for ( const fileGroup of phpSourceConfig.files ) {
    1036         const packageSrc = path.join( gutenbergPackagesDir, fileGroup.package );
    1037 
    1038         if ( ! fs.existsSync( packageSrc ) ) {
    1039             console.log( `   ⚠️  Package not found: ${ fileGroup.package }` );
    1040             continue;
    1041         }
    1042 
    1043         for ( const file of fileGroup.files ) {
    1044             const src = path.join( packageSrc, file );
    1045             const dest = path.join(
    1046                 wpIncludesDir,
    1047                 fileGroup.destination,
    1048                 file
    1049             );
    1050 
    1051             if ( fs.existsSync( src ) ) {
    1052                 fs.mkdirSync( path.dirname( dest ), { recursive: true } );
    1053                 let content = fs.readFileSync( src, 'utf8' );
    1054                 fs.writeFileSync( dest, content );
    1055             }
    1056         }
    1057         console.log(
    1058             `   ✅ ${ fileGroup.package } (${ fileGroup.files.length } files)`
    1059         );
    1060     }
    1061 
    1062     // 7. Copy theme JSON files (from Gutenberg lib directory)
     1015    // 6. Copy theme JSON files (from Gutenberg lib directory)
    10631016    console.log( '\n📦 Copying theme JSON files...' );
    10641017    const themeJsonConfig = COPY_CONFIG.themeJson;
     
    10871040    }
    10881041
    1089     // 9. Generate script-modules-packages.min.php from individual asset files
     1042    // 7. Generate script-modules-packages.min.php from individual asset files
    10901043    console.log( '\n📦 Generating script-modules-packages.min.php...' );
    10911044    generateScriptModulesPackages();
    10921045
    1093     // 10. Generate script-loader-packages.min.php
     1046    // 8. Generate script-loader-packages.min.php
    10941047    console.log( '\n📦 Generating script-loader-packages.min.php...' );
    10951048    generateScriptLoaderPackages();
    10961049
    1097     // 11. Generate require-dynamic-blocks.php and require-static-blocks.php
     1050    // 9. Generate require-dynamic-blocks.php and require-static-blocks.php
    10981051    console.log( '\n📦 Generating block registration files...' );
    10991052    generateBlockRegistrationFiles();
    11001053
    1101     // 12. Generate blocks-json.php from block.json files
     1054    // 10. Generate blocks-json.php from block.json files
    11021055    console.log( '\n📦 Generating blocks-json.php...' );
    11031056    generateBlocksJson();
Note: See TracChangeset for help on using the changeset viewer.