Skip to content

Commit e6d8284

Browse files
authored
Block Directory: Convert it to UI Plugin to avoid bundling into Core (WordPress#17576)
* Block Directory: Convert it to UI Plugin to avoid bundling into Core * Load the block directory assets only when the experiment is enabled * Try to reimplement asset overrides to give more flexibility * Add code style improvemements and perform code cleanup * Try to make PHP unit tests pass by removing group check * Ensure that packages and vendor scripts are printed in the footer * Fix the has action check for the block directory assets * Move gutenberg-block-directory experiment check out of the action * Fix bin/get-vendor-scripts.php
1 parent 876272d commit e6d8284

File tree

15 files changed

+251
-176
lines changed

15 files changed

+251
-176
lines changed

bin/get-vendor-scripts.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,13 @@ function wp_add_inline_script() {}
3232

3333
require_once dirname( dirname( __FILE__ ) ) . '/lib/client-assets.php';
3434

35-
gutenberg_register_vendor_scripts();
35+
/**
36+
* Hi, phpcs
37+
*/
38+
function run_gutenberg_register_vendor_scripts() {
39+
global $wp_scripts;
40+
41+
gutenberg_register_vendor_scripts( $wp_scripts );
42+
}
43+
44+
run_gutenberg_register_vendor_scripts();

lib/block-directory.php

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* Block directory functions.
4+
*
5+
* @package gutenberg
6+
*/
7+
8+
if (
9+
gutenberg_is_experiment_enabled( 'gutenberg-block-directory' ) &&
10+
! has_action( 'admin_enqueue_scripts', 'enqueue_block_editor_assets_block_directory' )
11+
) {
12+
/**
13+
* Function responsible for enqueuing the assets required
14+
* for the block directory functionality in the editor.
15+
*/
16+
function gutenberg_enqueue_block_editor_assets_block_directory() {
17+
wp_enqueue_script( 'wp-block-directory' );
18+
wp_enqueue_style( 'wp-block-directory' );
19+
}
20+
add_action( 'enqueue_block_editor_assets', 'gutenberg_enqueue_block_editor_assets_block_directory' );
21+
}

0 commit comments

Comments
 (0)