Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add block directory to inserter menu #17431

Merged
merged 160 commits into from
Sep 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
160 commits
Select commit Hold shift + click to select a range
1060588
Add new properties and panel for discover items
Jul 3, 2019
8fc202a
Add basic component with styling for discover blocks
Jul 3, 2019
ebd1148
Dynamically load block into editor.
Jul 3, 2019
e85b2a0
Increase icon size.
Jul 3, 2019
7dbdf01
Handle insert block properly.
Jul 3, 2019
673475e
Added another discover block.
Jul 3, 2019
069d796
Revert unncessary changes.
Jul 3, 2019
a02a3c7
Retrieve discover blocks from a mock api.
Jul 4, 2019
7824941
Only show discover blocks when no blocks are found.
Jul 7, 2019
e08184b
Style discover items header
Jul 7, 2019
b5e1756
Fill discover item footer elements.
Jul 8, 2019
810546b
Use BlockIcon components.
Jul 8, 2019
78e7883
Merged
Jul 8, 2019
e363149
Update documentation.
Jul 8, 2019
c67d4f3
Update mock URL.
Jul 8, 2019
bdda0cc
Revert changes in BlockIcon for size and use Icon directly.
Jul 9, 2019
acca61d
Use Fragment from wp.element.
Jul 9, 2019
049297f
Created BlockRatings component.
Jul 9, 2019
512b099
Update classNames to follow guidelines.
Jul 11, 2019
4b8e27a
Moved mock api to WordPress rest api.
Jul 12, 2019
a258146
Merged from upstream
Jul 14, 2019
9c2ab35
Separate DiscoverBlocksPanel to a component.
Jul 14, 2019
53e6e57
Implement basic block search.
Jul 14, 2019
d6cae04
Handle user without permission to install blocks.
Jul 14, 2019
0e4c81b
Styling for discover blocks search description.
Jul 14, 2019
97326c8
Handle error when script can't load.
Jul 15, 2019
c2d142a
Removed text to follow design.
Jul 15, 2019
4ddf8c7
Fixed search not returning as array from the mock API.
Jul 15, 2019
95bcc09
Refactor stars component to a shorter code using @talldan's recommend…
Jul 15, 2019
3745493
Renamed class names based on guideline and recommendation.
Jul 15, 2019
6633c6d
Make React avoid rendering style attribute when icon is falsey.
Jul 15, 2019
c1f7b11
Removed redundant styles.
Jul 15, 2019
5a225d8
Refactor DiscoverBlockListItem to smaller components.
Jul 15, 2019
9041d62
Renamed class names based on guideline and recommendation.
Jul 16, 2019
1d77f85
Align @param descriptions.
Jul 16, 2019
7774547
Removed redundant comments.
Jul 16, 2019
01c311b
Refactor DiscoverBlockListItem to smaller components.
Jul 16, 2019
b9baa64
Tidy up blocks search controller code.
Jul 16, 2019
37a0080
Implement Retry button when Block previews can't load.
Jul 17, 2019
16dfdfe
Implement block search to api.wordpress.org.
Jul 17, 2019
5882bde
Map plugin info to discover block.
Jul 18, 2019
2b930f0
Map available plugin properties to block.
Jul 18, 2019
d017ac0
Fix typo in comment.
Jul 18, 2019
52987f9
Map updated metadata from api.
Jul 18, 2019
038c141
Merge remote-tracking branch 'upstream/master' into try/discover-new-…
Jul 19, 2019
14c6d74
Updated unit test.
Jul 22, 2019
56b20fe
Show loading state when requesting for discover blocks.
Jul 22, 2019
b99c417
Only show uninstalled blocks.
Jul 23, 2019
92ac7cd
Prevent fetching if user has not typed anything.
Jul 23, 2019
52eb638
Update comments
Jul 23, 2019
9be2347
Debounce search for blocks.
Jul 24, 2019
b26dbda
Implement spinner for loading state.
Jul 24, 2019
953d3df
Merge remote-tracking branch 'upstream/master' into try/discover-new-…
Jul 25, 2019
19a2de9
Install and activate plugin after loading to editor.
Jul 25, 2019
c643d55
Handle error while installing block.
Jul 26, 2019
6449373
Added functionality to retry installing block.
Jul 29, 2019
75cc8d0
Use regular HTML attributes without string evaluation.
Jul 29, 2019
b563c43
Use shorthand property names.
Jul 29, 2019
6ed9aaa
Use WP_Error, improve and fix for feedback from PR.
Jul 29, 2019
22c7854
Change install REST methods to allow PUT and POST only.
Jul 30, 2019
fae82f8
Update REST to return response with snake case.
Jul 30, 2019
37444c5
Merge remote-tracking branch 'upstream/master' into try/discover-new-…
Jul 31, 2019
46dbf23
New downloadable-blocks package to fill a slot in inserter menu.
Aug 3, 2019
d9b0db5
Update documentation.
Aug 3, 2019
7a4fb2b
Passing props to downloadable blocks.
Aug 3, 2019
4444710
Moved components from block-editor to its own package.
Aug 4, 2019
bff4995
Load css for downloadable-blocks.
Aug 5, 2019
ac54237
Moved debounce filterValue function to editor.
Aug 5, 2019
89e5862
Moved to use its own data store in downloadable-blocks package.
Aug 5, 2019
20e0e79
Moved code to load block assets out of menu.js
Aug 6, 2019
b23ba87
Remove comment.
Aug 6, 2019
7a39b70
Removed block-icon from downloadable-blocks package.
Aug 6, 2019
b3bd752
Fixed bad reference in scss file.
Aug 6, 2019
b2352ff
Moved installBlock function to a be next to handleDownloadableBlock.
Aug 6, 2019
8a9603b
Moved the handleDownloadableBlock to actions.
Aug 6, 2019
2ec1a96
Renamed downloadable-blocks package to block-directory.
Aug 6, 2019
762a726
Export DiscoverBlocksPanel as named exports.
Aug 6, 2019
64ece6c
Update README and package.json.
Aug 6, 2019
4b3d836
Renamed store to core/block-directory.
Aug 6, 2019
e4cc959
Renamed css class name.
Aug 7, 2019
822bcc1
Renamed css class name.
Aug 7, 2019
d91f669
Renamed discover-block to downloadable-block
Aug 7, 2019
1ddab6c
Rename block-ratings to prefix with block-directory.
Aug 7, 2019
01be3e0
Rename rest controller to block directory.
Aug 7, 2019
7021e2e
Limit the number of words in description.
Aug 7, 2019
56a790a
Update background color to design specs.
Aug 7, 2019
5df0ffc
Refactor to call loadAssets asynchronously.
Aug 8, 2019
e25c6c6
Refactor downloadBlock and installBlock to be more extensible.
Aug 8, 2019
0d137f3
Rename handleDownloadableBlock to downloadBlock
Aug 8, 2019
fde3dca
Handle if FS_METHOD is not direct.
Aug 8, 2019
c270540
Fix retry of installing block.
Aug 8, 2019
3544494
Only install block after download is successful.
Aug 8, 2019
ed1bcb5
Fix onSelect of item on success.
Aug 8, 2019
36dd5a3
Remove block if failed to install block.
Aug 9, 2019
22f6a3d
Mereged from master
Aug 9, 2019
df46fdc
Update documentation.
Aug 9, 2019
e90876f
Check for permission before fetch.
Aug 9, 2019
765571b
Fix unit test
Aug 9, 2019
c0d1738
Uninstall new blocks if user has removed them.
Aug 12, 2019
9113882
Merged from master
Aug 12, 2019
bc3f77e
Remove debug messages from API.
Aug 12, 2019
d5f1db8
Fix bug to filter installedBlockType after uninstall.
Aug 12, 2019
e37c23d
Add dependencies into package.json
Aug 13, 2019
f65b493
Update package-lock.json
Aug 13, 2019
d766d67
Fix flickering when search for blocks.
Aug 13, 2019
b265d93
Update package.json
Aug 13, 2019
78e4566
Update package-lock.json
Aug 13, 2019
e0772d0
Fix the search results flickering.
Aug 15, 2019
345a1db
Update packages/block-directory/package.json
ck-lee Aug 15, 2019
5b0b5c9
Update packages/block-directory/package.json
ck-lee Aug 15, 2019
7840221
Update packages/block-directory/CHANGELOG.md
ck-lee Aug 15, 2019
4b3c898
Improve accessibility.
Aug 16, 2019
2e7889f
Merge branch 'try/discover-new-blocks' of github.com:ck-lee/gutenberg…
Aug 16, 2019
649982d
Remove redudant line.
Aug 18, 2019
e47e214
Rename the selector method.
Aug 18, 2019
e3bc38c
Remove isDownloadableBlocksEnabled settings.
Aug 18, 2019
bebbb23
Merged
Aug 19, 2019
dad8d44
Update data-core-block-editor.md
Aug 19, 2019
c877957
Added feature toggle for block directory in the experiment settings p…
Aug 20, 2019
d1f86f5
Update README.md
Aug 20, 2019
d1faced
Fix typo
Aug 20, 2019
f2bd345
Fixed phpcs errors.
Aug 21, 2019
d184693
Fix phpcs warning.
Aug 22, 2019
d0d832a
Rename REST base endpoint to block-directory.
Aug 22, 2019
711d908
Update comment for class.
Aug 22, 2019
3174112
Use noop instead of empty function.
Aug 22, 2019
1f4ad26
Rename discover blocks to downloadable blocks.
Aug 22, 2019
54a891c
Tidy up code.
Aug 22, 2019
2bab650
Update bottom section to be footer in an article.
Aug 22, 2019
8bb30b1
Merged from master
Aug 26, 2019
4a9c324
Fix phpcs warning.
Aug 26, 2019
d1687ad
Mapped author information for block directory
Aug 28, 2019
11978b1
Merged
Aug 28, 2019
868cd14
Merge remote-tracking branch 'upstream/master' into try/discover-new-…
Aug 28, 2019
3f5804e
Merge branch 'try/discover-new-blocks' of github.com:ck-lee/gutenberg…
Aug 28, 2019
15e0012
Merge remote-tracking branch 'upstream/master' into try/discover-new-…
ck-lee Sep 12, 2019
882d178
Remove experimental feature flag for block directory
talldan Sep 13, 2019
5546813
Fix block inner-content overflowing rounded corners
talldan Sep 13, 2019
78ac668
Remove superfluous css rule
talldan Sep 13, 2019
998108f
Use existing scss variables where possible
talldan Sep 13, 2019
4b6b77b
Use a `p` tag for the block description
talldan Sep 13, 2019
dae13c0
Remove @access comments
noisysocks Sep 13, 2019
3665762
s/get_items_permissions_check/permissions_check/
noisysocks Sep 13, 2019
360273d
Update @since to 6.5.0
noisysocks Sep 13, 2019
cea96a3
Mark parse_block_metadata() as private
noisysocks Sep 13, 2019
85249b2
Update @since to 6.5.0
noisysocks Sep 13, 2019
d516fbf
Include end of string anchor in image extension RegExp
noisysocks Sep 13, 2019
e1374c6
Remove item.isDisabled
noisysocks Sep 13, 2019
52f63fb
Use unicode apostrophe
noisysocks Sep 13, 2019
3532665
Improve spoken message
noisysocks Sep 13, 2019
be0a0ef
Improve copy
noisysocks Sep 13, 2019
9ce4501
Add whitespace
noisysocks Sep 13, 2019
d706552
Fix comments and remove unused params
talldan Sep 13, 2019
bf28d09
Pass storeConfig straight to registerStore
talldan Sep 13, 2019
089be60
Remove empty quotes
talldan Sep 13, 2019
54e0eb4
Use Array.isArray
talldan Sep 13, 2019
7d1a386
Add a comment explaining the block uninstall feature
talldan Sep 13, 2019
06fa42d
Fix plugin rating calculation
noisysocks Sep 13, 2019
613223f
s/isMenuEmpty/hasItems/
noisysocks Sep 13, 2019
1025568
Revert "Remove experimental feature flag for block directory"
talldan Sep 13, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/manifest-devhub.json
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,12 @@
"markdown_source": "../packages/blob/README.md",
"parent": "packages"
},
{
"title": "@wordpress/block-directory",
"slug": "packages-block-directory",
"markdown_source": "../packages/block-directory/README.md",
"parent": "packages"
},
{
"title": "@wordpress/block-editor",
"slug": "packages-block-editor",
Expand Down
307 changes: 307 additions & 0 deletions lib/class-wp-rest-block-directory-controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,307 @@
<?php
/**
* Start: Include for phase 2
* Block Directory REST API: WP_REST_Blocks_Controller class
*
* @package gutenberg
* @since 6.5.0
*/

/**
* Controller which provides REST endpoint for the blocks.
*
* @since 6.5.0
*
* @see WP_REST_Controller
*/
class WP_REST_Block_Directory_Controller extends WP_REST_Controller {

/**
* Constructs the controller.
*/
public function __construct() {
$this->namespace = '__experimental';
$this->rest_base = 'block-directory';
}

/**
* Registers the necessary REST API routes.
*/
public function register_routes() {
register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/search',
array(
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'get_items' ),
'permission_callback' => array( $this, 'permissions_check' ),
),
'schema' => array( $this, 'get_item_schema' ),
)
);
register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/install',
array(
array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => array( $this, 'install_block' ),
'permission_callback' => array( $this, 'permissions_check' ),
),
'schema' => array( $this, 'get_item_schema' ),
)
);
register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/uninstall',
array(
array(
'methods' => WP_REST_Server::DELETABLE,
'callback' => array( $this, 'uninstall_block' ),
'permission_callback' => array( $this, 'permissions_check' ),
),
'schema' => array( $this, 'get_item_schema' ),
)
);
}

/**
* Checks whether a given request has permission to install and activate plugins.
*
* @since 6.5.0
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|bool True if the request has permission, WP_Error object otherwise.
*/
public function permissions_check( $request ) {
if ( ! current_user_can( 'install_plugins' ) || ! current_user_can( 'activate_plugins' ) ) {
return new WP_Error(
'rest_user_cannot_view',
__( 'Sorry, you are not allowed to install blocks.', 'gutenberg' )
);
}

return true;
}

/**
* Installs and activates a plugin
*
* @since 6.5.0
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure.
*/
public function install_block( $request ) {

include_once( ABSPATH . 'wp-admin/includes/file.php' );
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );

$api = plugins_api(
'plugin_information',
array(
'slug' => $request->get_param( 'slug' ),
'fields' => array(
'sections' => false,
),
)
);

if ( is_wp_error( $api ) ) {
return WP_Error( $api->get_error_code(), $api->get_error_message() );
}

$skin = new WP_Ajax_Upgrader_Skin();
$upgrader = new Plugin_Upgrader( $skin );

$filesystem_method = get_filesystem_method();

if ( 'direct' !== $filesystem_method ) {
return WP_Error( null, 'Only direct FS_METHOD is supported.' );
}

$result = $upgrader->install( $api->download_link );

if ( is_wp_error( $result ) ) {
return WP_Error( $result->get_error_code(), $result->get_error_message() );
}

if ( is_wp_error( $skin->result ) ) {
return WP_Error( $skin->$result->get_error_code(), $skin->$result->get_error_message() );
}

if ( $skin->get_errors()->has_errors() ) {
return WP_Error( $skin->$result->get_error_code(), $skin->$result->get_error_messages() );
}

if ( is_null( $result ) ) {
global $wp_filesystem;
// Pass through the error from WP_Filesystem if one was raised.
if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) {
return WP_Error( 'unable_to_connect_to_filesystem', esc_html( $wp_filesystem->errors->get_error_message() ) );
}
return WP_Error( 'unable_to_connect_to_filesystem', __( 'Unable to connect to the filesystem. Please confirm your credentials.', 'gutenberg' ) );
}

$install_status = install_plugin_install_status( $api );

$activate_result = activate_plugin( $install_status['file'] );

if ( is_wp_error( $activate_result ) ) {
return WP_Error( $activate_result->get_error_code(), $activate_result->get_error_message() );
}

return rest_ensure_response( true );
}

/**
* Deactivates and deletes a plugin
*
* @since 6.5.0
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure.
*/
public function uninstall_block( $request ) {

include_once( ABSPATH . 'wp-admin/includes/file.php' );
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );

$api = plugins_api(
'plugin_information',
array(
'slug' => $request->get_param( 'slug' ),
'fields' => array(
'sections' => false,
),
)
);

if ( is_wp_error( $api ) ) {
return WP_Error( $api->get_error_code(), $api->get_error_message() );
}

$install_status = install_plugin_install_status( $api );

$deactivate_result = deactivate_plugins( $install_status['file'] );

if ( is_wp_error( $deactivate_result ) ) {
return WP_Error( $deactivate_result->get_error_code(), $deactivate_result->get_error_message() );
}

$delete_result = delete_plugins( array( $install_status['file'] ) );

if ( is_wp_error( $delete_result ) ) {
return WP_Error( $delete_result->get_error_code(), $delete_result->get_error_message() );
}

return rest_ensure_response( true );
}

/**
* Search and retrieve blocks metadata
*
* @since 6.5.0
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure.
*/
public function get_items( $request ) {

$search_string = $request->get_param( 'term' );

if ( empty( $search_string ) ) {
return rest_ensure_response( array() );
}

include( ABSPATH . WPINC . '/version.php' );

$url = 'http://api.wordpress.org/plugins/info/1.2/';
$url = add_query_arg(
array(
'action' => 'query_plugins',
'request[block]' => $search_string,
'request[wp_version]' => '5.3',
'request[per_page]' => '3',
),
$url
);
$http_url = $url;
$ssl = wp_http_supports( array( 'ssl' ) );
if ( $ssl ) {
$url = set_url_scheme( $url, 'https' );
}
$http_args = array(
'timeout' => 15,
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
);

$request = wp_remote_get( $url, $http_args );
$response = json_decode( wp_remote_retrieve_body( $request ), true );

if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}

$result = array();

foreach ( $response['plugins'] as $plugin ) {
$installed_plugins = get_plugins( '/' . $plugin['slug'] );

// Only show uninstalled blocks.
if ( empty( $installed_plugins ) ) {
$result[] = self::parse_block_metadata( $plugin );
}
}

return rest_ensure_response( $result );
}

/**
* Parse block metadata for a block
*
* @since 6.5.0
*
* @param WP_Object $plugin The plugin metadata.
* @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure.
*/
private static function parse_block_metadata( $plugin ) {
$block = new stdClass();

// There might be multiple blocks in a plugin. Only the first block is mapped.
$block_data = reset( $plugin['blocks'] );
$block->name = $block_data['name'];
$block->title = $block_data['title'];

// Plugin's description, not description in block.json.
$block->description = wp_trim_words( wp_strip_all_tags( $plugin['description'] ), 30, '...' );

$block->id = $plugin['slug'];
$block->rating = $plugin['rating'] / 20;
$block->rating_count = $plugin['num_ratings'];
$block->active_installs = $plugin['active_installs'];
$block->author_block_rating = $plugin['author_block_rating'] / 20;
$block->author_block_count = $plugin['author_block_count'];

// Plugin's author, not author in block.json.
$block->author = wp_strip_all_tags( $plugin['author'] );

// Plugin's icons or icon in block.json.
$block->icon = isset( $plugin['icons']['1x'] ) ? $plugin['icons']['1x'] : 'block-default';

$block->assets = array();

foreach ( $plugin['block_assets'] as $asset ) {
$block->assets[] = 'https://plugins.svn.wordpress.org/' . $plugin['slug'] . $asset;
}

$block->humanized_updated = human_time_diff( strtotime( $plugin['last_updated'] ), current_time( 'timestamp' ) ) . __( ' ago', 'gutenberg' );

return $block;
}
}
10 changes: 9 additions & 1 deletion lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ function gutenberg_register_scripts_and_styles() {
gutenberg_override_style(
'wp-editor',
gutenberg_url( 'build/editor/style.css' ),
array( 'wp-components', 'wp-block-editor', 'wp-nux' ),
array( 'wp-components', 'wp-block-editor', 'wp-nux', 'wp-block-directory' ),
filemtime( gutenberg_dir_path() . 'build/editor/style.css' )
);
wp_style_add_data( 'wp-editor', 'rtl', 'replace' );
Expand Down Expand Up @@ -373,6 +373,14 @@ function gutenberg_register_scripts_and_styles() {
);
wp_style_add_data( 'wp-edit-widgets', 'rtl', 'replace' );

gutenberg_override_style(
'wp-block-directory',
gutenberg_url( 'build/block-directory/style.css' ),
array( 'wp-components' ),
filemtime( gutenberg_dir_path() . 'build/block-directory/style.css' )
);
wp_style_add_data( 'wp-block-directory', 'rtl', 'replace' );

if ( defined( 'GUTENBERG_LIVE_RELOAD' ) && GUTENBERG_LIVE_RELOAD ) {
$live_reload_url = ( GUTENBERG_LIVE_RELOAD === true ) ? 'http://localhost:35729/livereload.js' : GUTENBERG_LIVE_RELOAD;

Expand Down
15 changes: 14 additions & 1 deletion lib/experiments-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class="wrap"
<?php settings_errors(); ?>
<form method="post" action="options.php">
<?php settings_fields( 'gutenberg-experiments' ); ?>
<?php do_settings_sections( 'gutenberg-experiments' ); ?>
<?php do_settings_sections( 'gutenberg-experiments' ); ?>
<?php submit_button(); ?>
</form>
</div>
Expand Down Expand Up @@ -64,6 +64,17 @@ function gutenberg_initialize_experiments_settings() {
'id' => 'gutenberg-menu-block',
)
);
add_settings_field(
'gutenberg-block-directory',
__( 'Block Directory', 'gutenberg' ),
'gutenberg_display_experiment_field',
'gutenberg-experiments',
'gutenberg_experiments_section',
array(
'label' => __( 'Enable Block Directory search', 'gutenberg' ),
'id' => 'gutenberg-block-directory',
)
);
register_setting(
'gutenberg-experiments',
'gutenberg-experiments'
Expand Down Expand Up @@ -114,6 +125,8 @@ function gutenberg_experiments_editor_settings( $settings ) {
$experiments_settings = array(
'__experimentalEnableLegacyWidgetBlock' => $experiments_exist ? array_key_exists( 'gutenberg-widget-experiments', get_option( 'gutenberg-experiments' ) ) : false,
'__experimentalEnableMenuBlock' => $experiments_exist ? array_key_exists( 'gutenberg-menu-block', get_option( 'gutenberg-experiments' ) ) : false,
'__experimentalBlockDirectory' => $experiments_exist ? array_key_exists( 'gutenberg-block-directory', get_option( 'gutenberg-experiments' ) ) : false,

);
return array_merge( $settings, $experiments_settings );
}
Expand Down
5 changes: 5 additions & 0 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
/**
* End: Include for phase 2
*/

if ( ! class_exists( 'WP_REST_Block_Directory_Controller' ) ) {
require dirname( __FILE__ ) . '/class-wp-rest-block-directory-controller.php';
}

require dirname( __FILE__ ) . '/rest-api.php';
}

Expand Down
Loading