Make WordPress Core

Changeset 53688


Ignore:
Timestamp:
07/08/2022 12:32:37 PM (23 months ago)
Author:
gziolo
Message:

Tools: Automate backporting core blocks from Gutenberg to Core

Syncing stable blocks from the Gutenberg repository to wordpress-develop was a manual process, but it got automated with the script that runs together with syncing WordPress packages changed in the Gutenberg package.

Props zieladam.
Fixes #56179.

Location:
trunk
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Gruntfile.js

    r53378 r53688  
    12471247         */
    12481248        grunt.task.run( 'wp-packages:refresh-deps' );
    1249 
    1250         // Build the files stored in the src/ directory.
    1251         grunt.task.run( 'build' );
    12521249    } );
    12531250
     
    16991696    } );
    17001697
     1698    grunt.registerTask( 'wp-packages:sync-stable-blocks', 'Refresh the PHP files referring to stable @wordpress/block-library blocks.', function() {
     1699        grunt.log.writeln( `Syncing stable blocks from @wordpress/block-library to src/` );
     1700        const { main } = require( './tools/release/sync-stable-blocks' );
     1701        main();
     1702    } );
     1703
    17011704    // Patch task.
    17021705    grunt.renameTask('patch_wordpress', 'patch');
  • trunk/package.json

    r53662 r53688  
    176176        "test:e2e": "node ./tests/e2e/run-tests.js",
    177177        "test:visual": "node ./tests/visual-regression/run-tests.js",
    178         "sync-gutenberg-packages": "grunt sync-gutenberg-packages --dev"
     178        "sync-gutenberg-packages": "grunt sync-gutenberg-packages",
     179        "postsync-gutenberg-packages": "grunt wp-packages:sync-stable-blocks && grunt build --dev && grunt build"
    179180    }
    180181}
  • trunk/src/wp-includes/blocks/index.php

    r53633 r53688  
    66 */
    77
     8define( 'BLOCKS_PATH', ABSPATH . WPINC . '/blocks/' );
     9
    810// Include files required for core blocks registration.
    9 require ABSPATH . WPINC . '/blocks/archives.php';
    10 require ABSPATH . WPINC . '/blocks/avatar.php';
    11 require ABSPATH . WPINC . '/blocks/block.php';
    12 require ABSPATH . WPINC . '/blocks/calendar.php';
    13 require ABSPATH . WPINC . '/blocks/categories.php';
    14 require ABSPATH . WPINC . '/blocks/comment-author-name.php';
    15 require ABSPATH . WPINC . '/blocks/comment-content.php';
    16 require ABSPATH . WPINC . '/blocks/comment-date.php';
    17 require ABSPATH . WPINC . '/blocks/comment-edit-link.php';
    18 require ABSPATH . WPINC . '/blocks/comment-reply-link.php';
    19 require ABSPATH . WPINC . '/blocks/comment-template.php';
    20 require ABSPATH . WPINC . '/blocks/comments-pagination.php';
    21 require ABSPATH . WPINC . '/blocks/comments-pagination-next.php';
    22 require ABSPATH . WPINC . '/blocks/comments-pagination-numbers.php';
    23 require ABSPATH . WPINC . '/blocks/comments-pagination-previous.php';
    24 require ABSPATH . WPINC . '/blocks/comments-title.php';
    25 require ABSPATH . WPINC . '/blocks/cover.php';
    26 require ABSPATH . WPINC . '/blocks/file.php';
    27 require ABSPATH . WPINC . '/blocks/gallery.php';
    28 require ABSPATH . WPINC . '/blocks/home-link.php';
    29 require ABSPATH . WPINC . '/blocks/image.php';
    30 require ABSPATH . WPINC . '/blocks/latest-comments.php';
    31 require ABSPATH . WPINC . '/blocks/latest-posts.php';
    32 require ABSPATH . WPINC . '/blocks/legacy-widget.php';
    33 require ABSPATH . WPINC . '/blocks/loginout.php';
    34 require ABSPATH . WPINC . '/blocks/navigation.php';
    35 require ABSPATH . WPINC . '/blocks/navigation-link.php';
    36 require ABSPATH . WPINC . '/blocks/navigation-submenu.php';
    37 require ABSPATH . WPINC . '/blocks/page-list.php';
    38 require ABSPATH . WPINC . '/blocks/pattern.php';
    39 require ABSPATH . WPINC . '/blocks/post-author.php';
    40 require ABSPATH . WPINC . '/blocks/post-author-biography.php';
    41 require ABSPATH . WPINC . '/blocks/post-comments.php';
    42 require ABSPATH . WPINC . '/blocks/post-comments-form.php';
    43 require ABSPATH . WPINC . '/blocks/post-content.php';
    44 require ABSPATH . WPINC . '/blocks/post-date.php';
    45 require ABSPATH . WPINC . '/blocks/post-excerpt.php';
    46 require ABSPATH . WPINC . '/blocks/post-featured-image.php';
    47 require ABSPATH . WPINC . '/blocks/post-navigation-link.php';
    48 require ABSPATH . WPINC . '/blocks/post-template.php';
    49 require ABSPATH . WPINC . '/blocks/post-terms.php';
    50 require ABSPATH . WPINC . '/blocks/post-title.php';
    51 require ABSPATH . WPINC . '/blocks/query.php';
    52 require ABSPATH . WPINC . '/blocks/query-no-results.php';
    53 require ABSPATH . WPINC . '/blocks/query-pagination.php';
    54 require ABSPATH . WPINC . '/blocks/query-pagination-next.php';
    55 require ABSPATH . WPINC . '/blocks/query-pagination-numbers.php';
    56 require ABSPATH . WPINC . '/blocks/query-pagination-previous.php';
    57 require ABSPATH . WPINC . '/blocks/query-title.php';
    58 require ABSPATH . WPINC . '/blocks/read-more.php';
    59 require ABSPATH . WPINC . '/blocks/rss.php';
    60 require ABSPATH . WPINC . '/blocks/search.php';
    61 require ABSPATH . WPINC . '/blocks/shortcode.php';
    62 require ABSPATH . WPINC . '/blocks/site-logo.php';
    63 require ABSPATH . WPINC . '/blocks/site-tagline.php';
    64 require ABSPATH . WPINC . '/blocks/site-title.php';
    65 require ABSPATH . WPINC . '/blocks/social-link.php';
    66 require ABSPATH . WPINC . '/blocks/tag-cloud.php';
    67 require ABSPATH . WPINC . '/blocks/template-part.php';
    68 require ABSPATH . WPINC . '/blocks/term-description.php';
    69 require ABSPATH . WPINC . '/blocks/widget-group.php';
     11require BLOCKS_PATH . 'legacy-widget.php';
     12require BLOCKS_PATH . 'widget-group.php';
     13require BLOCKS_PATH . 'require-dynamic-blocks.php';
    7014
    7115/**
     
    7620 */
    7721function register_core_block_types_from_metadata() {
    78     $block_folders = array(
    79         'audio',
    80         'button',
    81         'buttons',
    82         'code',
    83         'column',
    84         'columns',
    85         'comments-query-loop',
    86         'embed',
    87         'freeform',
    88         'group',
    89         'heading',
    90         'html',
    91         'list',
    92         'media-text',
    93         'missing',
    94         'more',
    95         'nextpage',
    96         'paragraph',
    97         'preformatted',
    98         'pullquote',
    99         'quote',
    100         'separator',
    101         'social-links',
    102         'spacer',
    103         'table',
    104         'text-columns',
    105         'verse',
    106         'video',
    107     );
    108 
     22    $block_folders = require BLOCKS_PATH . 'require-static-blocks.php';
    10923    foreach ( $block_folders as $block_folder ) {
    11024        register_block_type(
    111             ABSPATH . WPINC . '/blocks/' . $block_folder
     25            BLOCKS_PATH . $block_folder
    11226        );
    11327    }
  • trunk/tests/phpunit/includes/functions.php

    r53635 r53688  
    333333 */
    334334function _unhook_block_registration() {
    335     remove_action( 'init', 'register_block_core_archives' );
    336     remove_action( 'init', 'register_block_core_avatar' );
    337     remove_action( 'init', 'register_block_core_block' );
    338     remove_action( 'init', 'register_block_core_calendar' );
    339     remove_action( 'init', 'register_block_core_categories' );
    340     remove_action( 'init', 'register_block_core_comment_author_name' );
    341     remove_action( 'init', 'register_block_core_comment_content' );
    342     remove_action( 'init', 'register_block_core_comment_date' );
    343     remove_action( 'init', 'register_block_core_comment_edit_link' );
    344     remove_action( 'init', 'register_block_core_comment_reply_link' );
    345     remove_action( 'init', 'register_block_core_comment_template' );
    346     remove_action( 'init', 'register_block_core_comments_pagination' );
    347     remove_action( 'init', 'register_block_core_comments_pagination_next' );
    348     remove_action( 'init', 'register_block_core_comments_pagination_numbers' );
    349     remove_action( 'init', 'register_block_core_comments_pagination_previous' );
    350     remove_action( 'init', 'register_block_core_comments_title' );
    351     remove_action( 'init', 'register_block_core_cover' );
    352     remove_action( 'init', 'register_block_core_file' );
    353     remove_action( 'init', 'register_block_core_gallery' );
    354     remove_action( 'init', 'register_block_core_home_link' );
    355     remove_action( 'init', 'register_block_core_image' );
    356     remove_action( 'init', 'register_block_core_latest_comments' );
    357     remove_action( 'init', 'register_block_core_latest_posts' );
     335    require __DIR__ . '/unregister-blocks-hooks.php';
     336    remove_action( 'init', 'register_core_block_types_from_metadata' );
    358337    remove_action( 'init', 'register_block_core_legacy_widget' );
    359     remove_action( 'init', 'register_block_core_loginout' );
    360     remove_action( 'init', 'register_block_core_navigation' );
    361     remove_action( 'init', 'register_block_core_navigation_link' );
    362     remove_action( 'init', 'register_block_core_navigation_submenu' );
    363     remove_action( 'init', 'register_block_core_page_list' );
    364     remove_action( 'init', 'register_block_core_pattern' );
    365     remove_action( 'init', 'register_block_core_post_author' );
    366     remove_action( 'init', 'register_block_core_post_author_biography' );
    367     remove_action( 'init', 'register_block_core_post_comments' );
    368     remove_action( 'init', 'register_block_core_post_comments_form' );
    369     remove_action( 'init', 'register_block_core_post_content' );
    370     remove_action( 'init', 'register_block_core_post_date' );
    371     remove_action( 'init', 'register_block_core_post_excerpt' );
    372     remove_action( 'init', 'register_block_core_post_featured_image' );
    373     remove_action( 'init', 'register_block_core_post_navigation_link' );
    374     remove_action( 'init', 'register_block_core_post_template' );
    375     remove_action( 'init', 'register_block_core_post_terms' );
    376     remove_action( 'init', 'register_block_core_post_title' );
    377     remove_action( 'init', 'register_block_core_query' );
    378     remove_action( 'init', 'register_block_core_query_no_results' );
    379     remove_action( 'init', 'register_block_core_query_pagination' );
    380     remove_action( 'init', 'register_block_core_query_pagination_next' );
    381     remove_action( 'init', 'register_block_core_query_pagination_numbers' );
    382     remove_action( 'init', 'register_block_core_query_pagination_previous' );
    383     remove_action( 'init', 'register_block_core_query_title' );
    384     remove_action( 'init', 'register_block_core_read_more' );
    385     remove_action( 'init', 'register_block_core_rss' );
    386     remove_action( 'init', 'register_block_core_search' );
    387     remove_action( 'init', 'register_block_core_shortcode' );
    388     remove_action( 'init', 'register_block_core_site_logo' );
    389     remove_action( 'init', 'register_block_core_site_tagline' );
    390     remove_action( 'init', 'register_block_core_site_title' );
    391     remove_action( 'init', 'register_block_core_social_link' );
    392     remove_action( 'init', 'register_block_core_tag_cloud' );
    393     remove_action( 'init', 'register_block_core_template_part' );
    394     remove_action( 'init', 'register_block_core_term_description' );
    395338    remove_action( 'init', 'register_block_core_widget_group' );
    396339    remove_action( 'init', 'register_core_block_types_from_metadata' );
Note: See TracChangeset for help on using the changeset viewer.