Skip to content

Commit

Permalink
Merge pull request #1221 from greenpeace/planet-5460
Browse files Browse the repository at this point in the history
PLANET-5460 Disable Wordpress(wp5.5) Blocks Directory feature
  • Loading branch information
sagarsdeshmukh authored Nov 10, 2020
2 parents c85e347 + cb1c468 commit 6036580
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/MasterSite.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ function ( $block_content, $block ) {
add_action( 'admin_notices', [ $this, 'show_dashboard_notice' ] );
add_action( 'wp_ajax_dismiss_dashboard_notice', [ $this, 'dismiss_dashboard_notice' ] );
add_filter( 'timber/twig', [ $this, 'p4_optimize_img_url' ] );

// Disable WordPress(WP5.5) Block Directory.
$this->disable_block_directory();
}

/**
Expand Down Expand Up @@ -1279,4 +1282,24 @@ public function img_to_cloudflare(

return $source;
}

/**
* Remove block directory assets and rest endpoint.
*/
public function disable_block_directory(): void {
remove_action( 'enqueue_block_editor_assets', 'wp_enqueue_editor_block_directory_assets' );
add_filter( 'rest_endpoints', [ $this, 'disable_block_directory_endpoint' ] );
}

/**
* Remove block directory endpoint.
*
* @param array $endpoints The available endpoints.
*
* @return array
*/
public function disable_block_directory_endpoint( array $endpoints ): array {
unset( $endpoints['/wp/v2/block-directory/search'] );
return $endpoints;
}
}

0 comments on commit 6036580

Please sign in to comment.