From 4844bcbe76e85cbd59ac9422b22649c7c9655afe Mon Sep 17 00:00:00 2001
From: agata <agata@insiberia.net>
Date: Fri, 2 Sep 2022 19:04:29 +0200
Subject: [PATCH] blocks allowed test

---
 ai-blocks.php | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/ai-blocks.php b/ai-blocks.php
index 8ebe708..43f7b0b 100644
--- a/ai-blocks.php
+++ b/ai-blocks.php
@@ -8,18 +8,17 @@
 * Author URI: https://autistici.org
 **/
 
+function wpdocs_allowed_block_types ( $block_editor_context, $editor_context ) {
+    if ( ! empty( $editor_context->post ) ) {
+        return array(
+            'core/paragraph',
+            'core/heading',
+            'core/list',
+        );
+    }
  
-function blacklist_blocks( $allowed_blocks ) {
-	// get all the registered blocks
-	$blocks = WP_Block_Type_Registry::get_instance()->get_all_registered();
-
-	// then disable some of them
-	unset( $blocks[ 'core/embed' ] );
-
-	// return the new list of allowed blocks
-	return array_keys( $blocks );
-	
+    return $block_editor_context;
 }
-
-add_filter( 'allowed_block_types_all', 'blacklist_blocks' );
+ 
+add_filter( 'allowed_block_types_all', 'wpdocs_allowed_block_types', 10, 2 );
 
-- 
GitLab