Make WordPress Core

Changeset 48262


Ignore:
Timestamp:
07/01/2020 12:27:10 PM (4 years ago)
Author:
gziolo
Message:

Editor: Register core blocks on the server

Exposes all core blocks (excluding embeds) on the server to be used with the REST API block types endpoint.

Props spacedmonkey, timothyblynjacobs.
Fixes #50263.

Location:
trunk
Files:
61 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-settings.php

    r48242 r48262  
    286286require ABSPATH . WPINC . '/class-wp-block-parser.php';
    287287require ABSPATH . WPINC . '/blocks.php';
    288 require ABSPATH . WPINC . '/blocks/archives.php';
    289 require ABSPATH . WPINC . '/blocks/block.php';
    290 require ABSPATH . WPINC . '/blocks/calendar.php';
    291 require ABSPATH . WPINC . '/blocks/categories.php';
    292 require ABSPATH . WPINC . '/blocks/latest-comments.php';
    293 require ABSPATH . WPINC . '/blocks/latest-posts.php';
    294 require ABSPATH . WPINC . '/blocks/rss.php';
    295 require ABSPATH . WPINC . '/blocks/search.php';
    296 require ABSPATH . WPINC . '/blocks/shortcode.php';
    297 require ABSPATH . WPINC . '/blocks/social-link.php';
    298 require ABSPATH . WPINC . '/blocks/tag-cloud.php';
     288require ABSPATH . WPINC . '/blocks/index.php';
    299289
    300290$GLOBALS['wp_embed'] = new WP_Embed();
  • trunk/tools/webpack/packages.js

    r47471 r48262  
    103103    };
    104104
    105     const blockNames = [
     105    const dynamicBlockFolders = [
    106106        'archives',
    107107        'block',
     
    116116        'tag-cloud',
    117117    ];
     118    const blockFolders = [
     119        'audio',
     120        'button',
     121        'buttons',
     122        'classic',
     123        'code',
     124        'column',
     125        'columns',
     126        'file',
     127        'gallery',
     128        'group',
     129        'heading',
     130        'html',
     131        'image',
     132        'list',
     133        'media-text',
     134        'missing',
     135        'more',
     136        'nextpage',
     137        'paragraph',
     138        'preformatted',
     139        'pullquote',
     140        'quote',
     141        'separator',
     142        'social-links',
     143        'spacer',
     144        'subhead',
     145        'table',
     146        'text-columns',
     147        'verse',
     148        'video',
     149        ...dynamicBlockFolders,
     150    ];
    118151    const phpFiles = {
    119152        'block-serialization-default-parser/parser.php': 'wp-includes/class-wp-block-parser.php',
    120         ...blockNames.reduce( ( files, blockName ) => {
     153        ...dynamicBlockFolders.reduce( ( files, blockName ) => {
    121154            files[ `block-library/src/${ blockName }/index.php` ] = `wp-includes/blocks/${ blockName }.php`;
    122155            return files;
    123156        } , {} ),
    124157    };
    125     const blockMetadataCopies = {
    126         from: join( baseDir, `node_modules/@wordpress/block-library/src/+(${ blockNames.join( '|' ) })/block.json` ),
    127         test: new RegExp( `\/([^/]+)\/block\.json$` ),
    128         to: join( baseDir, `${ buildTarget }/blocks/[1]/block.json` ),
     158    const blockMetadataFiles = {
     159        ...blockFolders.reduce( ( files, blockName ) => {
     160            files[ `block-library/src/${ blockName }/block.json` ] = `wp-includes/blocks/${ blockName }/block.json`;
     161            return files;
     162        } , {} ),
    129163    };
    130164
     
    171205        from: join( baseDir, `node_modules/@wordpress/${ filename }` ),
    172206        to: join( baseDir, `src/${ phpFiles[ filename ] }` ),
     207    } ) );
     208
     209    const blockMetadataCopies = Object.keys( blockMetadataFiles ).map( ( filename ) => ( {
     210        from: join( baseDir, `node_modules/@wordpress/${ filename }` ),
     211        to: join( baseDir, `src/${ blockMetadataFiles[ filename ] }` ),
    173212    } ) );
    174213
     
    255294                    ...cssCopies,
    256295                    ...phpCopies,
    257                     blockMetadataCopies,
     296                    ...blockMetadataCopies,
    258297                ],
    259298            ),
Note: See TracChangeset for help on using the changeset viewer.