Skip to content

Commit

Permalink
Block Directory: Convert it to UI Plugin to avoid bundling into Core (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
gziolo authored and hypest committed Nov 4, 2019
1 parent 94d2a13 commit f08558e
Show file tree
Hide file tree
Showing 15 changed files with 251 additions and 176 deletions.
11 changes: 10 additions & 1 deletion bin/get-vendor-scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,13 @@ function wp_add_inline_script() {}

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

gutenberg_register_vendor_scripts();
/**
* Hi, phpcs
*/
function run_gutenberg_register_vendor_scripts() {
global $wp_scripts;

gutenberg_register_vendor_scripts( $wp_scripts );
}

run_gutenberg_register_vendor_scripts();
21 changes: 21 additions & 0 deletions lib/block-directory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* Block directory functions.
*
* @package gutenberg
*/

if (
gutenberg_is_experiment_enabled( 'gutenberg-block-directory' ) &&
! has_action( 'admin_enqueue_scripts', 'enqueue_block_editor_assets_block_directory' )
) {
/**
* Function responsible for enqueuing the assets required
* for the block directory functionality in the editor.
*/
function gutenberg_enqueue_block_editor_assets_block_directory() {
wp_enqueue_script( 'wp-block-directory' );
wp_enqueue_style( 'wp-block-directory' );
}
add_action( 'enqueue_block_editor_assets', 'gutenberg_enqueue_block_editor_assets_block_directory' );
}
Loading

0 comments on commit f08558e

Please sign in to comment.