From d5bd454324bd4a7860f33d40c8808bda7606cdb8 Mon Sep 17 00:00:00 2001 From: Fabian Todt Date: Mon, 13 Nov 2023 12:18:33 +0100 Subject: [PATCH 1/7] register variations on taxonomy registration --- .../block-library/src/post-terms/index.php | 78 ++++++++++++++----- 1 file changed, 60 insertions(+), 18 deletions(-) diff --git a/packages/block-library/src/post-terms/index.php b/packages/block-library/src/post-terms/index.php index 44291038383d42..954e0d8f7782b1 100644 --- a/packages/block-library/src/post-terms/index.php +++ b/packages/block-library/src/post-terms/index.php @@ -1,6 +1,6 @@ $taxonomy->name, + 'title' => $taxonomy->label, + 'description' => sprintf( + /* translators: %s: taxonomy's label */ + __( 'Display a list of assigned terms from the taxonomy: %s' ), + $taxonomy->label + ), + 'attributes' => array( + 'term' => $taxonomy->name, + ), + 'isActive' => array( 'term' ), + 'scope' => array( 'inserter', 'transform' ), + ); + + return $variation; +} + +/** + * Registers the `core/post-terms` block on the server. */ -function build_post_term_block_variations() { +function register_block_core_post_terms() { + // This will only handle taxonomies registered until this point (init on priority 9). + // See action hooks below for other taxonomies. + // See https://github.com/WordPress/gutenberg/issues/52569 for details. $taxonomies = get_taxonomies( array( 'publicly_queryable' => true, @@ -80,20 +107,7 @@ function build_post_term_block_variations() { // Create and register the eligible taxonomies variations. foreach ( $taxonomies as $taxonomy ) { - $variation = array( - 'name' => $taxonomy->name, - 'title' => $taxonomy->label, - 'description' => sprintf( - /* translators: %s: taxonomy's label */ - __( 'Display a list of assigned terms from the taxonomy: %s' ), - $taxonomy->label - ), - 'attributes' => array( - 'term' => $taxonomy->name, - ), - 'isActive' => array( 'term' ), - 'scope' => array( 'inserter', 'transform' ), - ); + $variation = block_core_post_terms_build_variation_for_post_terms( $taxonomy ); // Set the category variation as the default one. if ( 'category' === $taxonomy->name ) { $variation['isDefault'] = true; @@ -121,3 +135,31 @@ function register_block_core_post_terms() { ); } add_action( 'init', 'register_block_core_post_terms' ); +// Register actions for all taxonomies, to add variations when they are registered. +// All taxonomies registered before register_block_core_post_terms, will be handled by that function. +add_action( 'registered_taxonomy', 'register_block_core_post_terms_taxonomy_variation', 10, 3 ); + +/** + * Register a custom taxonomy variation for post terms on taxonomy registration + * Handles all taxonomies registered after the block is registered in register_block_core_post_terms + * + * @param string $taxonomy Taxonomy slug. + * @param array|string $object_type Object type or array of object types. + * @param array $args Array of taxonomy registration arguments. + * @return void + */ +function register_block_core_post_terms_taxonomy_variation( $taxonomy, $object_type, $args ) { + if ( isset( $args['show_in_nav_menus'] ) && $args['show_in_nav_menus'] ) { + $variation = block_core_post_terms_build_variation_for_post_terms( (object) $args ); + // Directly set the variations on the registered block type + // because there's no server side registration for variations (see #47170). + $post_terms_block_type = WP_Block_Type_Registry::get_instance()->get_registered( 'core/post-terms' ); + // If the block is not registered yet, bail early. + // Variation will be registered in register_block_core_post_terms then. + if ( ! $post_terms_block_type ) { + return; + } + + $post_terms_block_type->variations[] = $variation; + } +} From 37040be8d2487304ea618d9a6c6b5520ec32ac25 Mon Sep 17 00:00:00 2001 From: Fabian Todt Date: Mon, 13 Nov 2023 12:18:39 +0100 Subject: [PATCH 2/7] add unit test for variations --- .../block-post-terms-variations-test.php | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 phpunit/blocks/block-post-terms-variations-test.php diff --git a/phpunit/blocks/block-post-terms-variations-test.php b/phpunit/blocks/block-post-terms-variations-test.php new file mode 100644 index 00000000000000..e9f7209cde4071 --- /dev/null +++ b/phpunit/blocks/block-post-terms-variations-test.php @@ -0,0 +1,63 @@ + array( + 'name' => 'Book Type', + ), + ) + ); + } + + public function tear_down() { + unregister_taxonomy( 'book_type' ); + parent::tear_down(); + } + + /** + * @covers ::register_block_core_post_terms_variation + */ + public function test_post_terms_variations_custom_taxonomy() { + $registry = WP_Block_Type_Registry::get_instance(); + $post_terms_block = $registry->get_registered( 'core/post-terms' ); + $this->assertNotEmpty( $post_terms_block->variations, 'Block has no variations' ); + $variation = $this->get_variation_by_name( 'book_type', $post_terms_block->variations ); + $this->assertIsArray( $variation, 'Block variation is not an array' ); + $this->assertArrayHasKey( 'title', $variation, 'Block variation has no title' ); + $this->assertEquals( 'Book Type', $variation['title'], 'Variation title is different than the taxonomy label' ); + } + + /** + * Get a variation by its name from an array of variations. + * + * @param string $variation_name The name (= slug) of the variation. + * @param array $variations An array of variations. + * @return array|null The found variation or null. + */ + private function get_variation_by_name( $variation_name, $variations ) { + $found_variation = null; + foreach ( $variations as $variation ) { + if ( $variation['name'] === $variation_name ) { + $found_variation = $variation; + } + } + + return $found_variation; + } +} From 5619d93711a45e79ff4757fba34e77c7b8fd1534 Mon Sep 17 00:00:00 2001 From: Fabian Todt Date: Mon, 13 Nov 2023 12:40:20 +0100 Subject: [PATCH 3/7] fix public check for taxonomies --- packages/block-library/src/post-terms/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/post-terms/index.php b/packages/block-library/src/post-terms/index.php index 954e0d8f7782b1..85a207e1fd7bd3 100644 --- a/packages/block-library/src/post-terms/index.php +++ b/packages/block-library/src/post-terms/index.php @@ -149,7 +149,7 @@ function register_block_core_post_terms() { * @return void */ function register_block_core_post_terms_taxonomy_variation( $taxonomy, $object_type, $args ) { - if ( isset( $args['show_in_nav_menus'] ) && $args['show_in_nav_menus'] ) { + if ( isset( $args['publicly_queryable'] ) && $args['publicly_queryable'] ) { $variation = block_core_post_terms_build_variation_for_post_terms( (object) $args ); // Directly set the variations on the registered block type // because there's no server side registration for variations (see #47170). From b442ce1ac18b960d13d42bb6ab004eb5408f59bb Mon Sep 17 00:00:00 2001 From: Fabian Todt Date: Mon, 13 Nov 2023 12:46:21 +0100 Subject: [PATCH 4/7] add unit test for private taxonomies --- .../block-post-terms-variations-test.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/phpunit/blocks/block-post-terms-variations-test.php b/phpunit/blocks/block-post-terms-variations-test.php index e9f7209cde4071..7afadd1781df49 100644 --- a/phpunit/blocks/block-post-terms-variations-test.php +++ b/phpunit/blocks/block-post-terms-variations-test.php @@ -23,10 +23,22 @@ public function set_up() { ), ) ); + + register_taxonomy( + 'private_book_type', + array( 'post' ), + array( + 'labels' => array( + 'name' => 'Book Type', + ), + 'publicly_queryable' => false, + ) + ); } public function tear_down() { unregister_taxonomy( 'book_type' ); + unregister_taxonomy( 'private_book_type' ); parent::tear_down(); } @@ -43,6 +55,17 @@ public function test_post_terms_variations_custom_taxonomy() { $this->assertEquals( 'Book Type', $variation['title'], 'Variation title is different than the taxonomy label' ); } + /** + * @covers ::register_block_core_post_terms_variation + */ + public function test_post_terms_variations_custom_private_taxonomy() { + $registry = WP_Block_Type_Registry::get_instance(); + $post_terms_block = $registry->get_registered( 'core/post-terms' ); + $this->assertNotEmpty( $post_terms_block->variations, 'Block has no variations' ); + $variation = $this->get_variation_by_name( 'private_book_type', $post_terms_block->variations ); + $this->assertEmpty( $variation, 'Block variation for private taxonomy exists.' ); + } + /** * Get a variation by its name from an array of variations. * From f32a7d56f942ce1778ca6ba444276d158f1d0b0d Mon Sep 17 00:00:00 2001 From: Fabian Todt Date: Tue, 14 Nov 2023 09:25:00 +0100 Subject: [PATCH 5/7] handle taxonomy unregistration --- .../block-library/src/post-terms/index.php | 30 +++++++++++++++-- .../block-post-terms-variations-test.php | 33 +++++++++++++++++-- 2 files changed, 58 insertions(+), 5 deletions(-) diff --git a/packages/block-library/src/post-terms/index.php b/packages/block-library/src/post-terms/index.php index 85a207e1fd7bd3..169cbe4ceb5d46 100644 --- a/packages/block-library/src/post-terms/index.php +++ b/packages/block-library/src/post-terms/index.php @@ -137,7 +137,8 @@ function register_block_core_post_terms() { add_action( 'init', 'register_block_core_post_terms' ); // Register actions for all taxonomies, to add variations when they are registered. // All taxonomies registered before register_block_core_post_terms, will be handled by that function. -add_action( 'registered_taxonomy', 'register_block_core_post_terms_taxonomy_variation', 10, 3 ); +add_action( 'registered_taxonomy', 'block_core_post_terms_register_taxonomy_variation', 10, 3 ); +add_action( 'unregistered_taxonomy', 'block_core_post_terms_unregister_taxonomy_variation', 10, 3 ); /** * Register a custom taxonomy variation for post terms on taxonomy registration @@ -148,7 +149,7 @@ function register_block_core_post_terms() { * @param array $args Array of taxonomy registration arguments. * @return void */ -function register_block_core_post_terms_taxonomy_variation( $taxonomy, $object_type, $args ) { +function block_core_post_terms_register_taxonomy_variation( $taxonomy, $object_type, $args ) { if ( isset( $args['publicly_queryable'] ) && $args['publicly_queryable'] ) { $variation = block_core_post_terms_build_variation_for_post_terms( (object) $args ); // Directly set the variations on the registered block type @@ -163,3 +164,28 @@ function register_block_core_post_terms_taxonomy_variation( $taxonomy, $object_t $post_terms_block_type->variations[] = $variation; } } + +/** + * Unregisters a custom taxonomy variation for post terms block on taxonomy unregistration. + * + * @param string $taxonomy The taxonomy name passed from unregistered_taxonomy action hook. + * @return void + */ +function block_core_post_terms_unregister_taxonomy_variation( $taxonomy ) { + // Directly get the variations from the registered block type + // because there's no server side (un)registration for variations (see #47170). + $post_terms_block_type = WP_Block_Type_Registry::get_instance()->get_registered( 'core/post-terms' ); + // If the block is not registered (yet), there's no need to remove a variation. + if ( ! $post_terms_block_type || empty( $post_terms_block_type->variations ) ) { + return; + } + // Search for the variation and remove it from the array. + foreach ( $post_terms_block_type->variations as $i => $variation ) { + if ( $variation['name'] === $taxonomy ) { + unset( $post_terms_block_type->variations[ $i ] ); + break; + } + } + // Reindex array after removing one variation. + $post_terms_block_type->variations = array_values( $post_terms_block_type->variations ); +} diff --git a/phpunit/blocks/block-post-terms-variations-test.php b/phpunit/blocks/block-post-terms-variations-test.php index 7afadd1781df49..dcb48fb42cb1b1 100644 --- a/phpunit/blocks/block-post-terms-variations-test.php +++ b/phpunit/blocks/block-post-terms-variations-test.php @@ -39,24 +39,25 @@ public function set_up() { public function tear_down() { unregister_taxonomy( 'book_type' ); unregister_taxonomy( 'private_book_type' ); + unregister_taxonomy( 'temp_book_type' ); parent::tear_down(); } /** - * @covers ::register_block_core_post_terms_variation + * @covers ::block_core_post_terms_register_taxonomy_variation */ public function test_post_terms_variations_custom_taxonomy() { $registry = WP_Block_Type_Registry::get_instance(); $post_terms_block = $registry->get_registered( 'core/post-terms' ); $this->assertNotEmpty( $post_terms_block->variations, 'Block has no variations' ); $variation = $this->get_variation_by_name( 'book_type', $post_terms_block->variations ); - $this->assertIsArray( $variation, 'Block variation is not an array' ); + $this->assertIsArray( $variation, 'Block variation does not exist' ); $this->assertArrayHasKey( 'title', $variation, 'Block variation has no title' ); $this->assertEquals( 'Book Type', $variation['title'], 'Variation title is different than the taxonomy label' ); } /** - * @covers ::register_block_core_post_terms_variation + * @covers ::block_core_post_terms_register_taxonomy_variation */ public function test_post_terms_variations_custom_private_taxonomy() { $registry = WP_Block_Type_Registry::get_instance(); @@ -66,6 +67,32 @@ public function test_post_terms_variations_custom_private_taxonomy() { $this->assertEmpty( $variation, 'Block variation for private taxonomy exists.' ); } + /** + * @covers ::block_core_post_terms_unregister_taxonomy_variation + */ + public function test_post_terms_variations_unregister_taxonomy() { + register_taxonomy( + 'temp_book_type', + 'custom_book', + array( + 'labels' => array( + 'name' => 'Book Type', + ), + ) + ); + + $registry = WP_Block_Type_Registry::get_instance(); + $post_terms_block = $registry->get_registered( 'core/post-terms' ); + $this->assertNotEmpty( $post_terms_block->variations, 'Block has no variations' ); + $variation = $this->get_variation_by_name( 'temp_book_type', $post_terms_block->variations ); + $this->assertIsArray( $variation, 'Block variation does not exist' ); + + unregister_taxonomy( 'temp_book_type' ); + + $variation = $this->get_variation_by_name( 'temp_book_type', $post_terms_block->variations ); + $this->assertEmpty( $variation, 'Block variation still exists' ); + } + /** * Get a variation by its name from an array of variations. * From 11fe78efb09d57a111828c468f92ec5d34defa4d Mon Sep 17 00:00:00 2001 From: Fabian Todt Date: Mon, 29 Jan 2024 10:45:08 +0100 Subject: [PATCH 6/7] fix WP_Block_Type::$variations changes --- .../block-library/src/post-terms/index.php | 91 ++++++++++++------- phpcs.xml.dist | 1 + .../block-post-terms-variations-test.php | 8 +- 3 files changed, 66 insertions(+), 34 deletions(-) diff --git a/packages/block-library/src/post-terms/index.php b/packages/block-library/src/post-terms/index.php index 169cbe4ceb5d46..35a65a100c6dd9 100644 --- a/packages/block-library/src/post-terms/index.php +++ b/packages/block-library/src/post-terms/index.php @@ -65,7 +65,7 @@ function render_block_core_post_terms( $attributes, $content, $block ) { * * @return array */ -function block_core_post_terms_build_variation_for_post_terms( $taxonomy ) { +function build_variation_for_post_terms( $taxonomy ) { $variation = array( 'name' => $taxonomy->name, 'title' => $taxonomy->label, @@ -85,9 +85,59 @@ function block_core_post_terms_build_variation_for_post_terms( $taxonomy ) { } /** - * Registers the `core/post-terms` block on the server. + * Register a variation for a taxonomy for the post-terms block. + * + * @param array $variation Variation array from build_variation_for_post_terms. + * @return void */ -function register_block_core_post_terms() { +function block_core_post_terms_register_variation( $variation ) { + // Directly set the variations on the registered block type + // because there's no server side registration for variations (see #47170). + $navigation_block_type = WP_Block_Type_Registry::get_instance()->get_registered( 'core/post-terms' ); + // If the block is not registered yet, bail early. + // Variation will be registered in register_block_core_post_terms then. + if ( ! $navigation_block_type ) { + return; + } + + $navigation_block_type->variations = array_merge( + $navigation_block_type->variations, + array( $variation ) + ); +} + +/** + * Unregister a variation for a taxonomy for the post-terms block. + * + * @param string $name Name of the taxonomy (which was used as variation name). + * @return void + */ +function block_core_post_terms_unregister_variation( $name ) { + // Directly get the variations from the registered block type + // because there's no server side (un)registration for variations (see #47170). + $navigation_block_type = WP_Block_Type_Registry::get_instance()->get_registered( 'core/post-terms' ); + // If the block is not registered (yet), there's no need to remove a variation. + if ( ! $navigation_block_type || empty( $navigation_block_type->variations ) ) { + return; + } + $variations = $navigation_block_type->variations; + // Search for the variation and remove it from the array. + foreach ( $variations as $i => $variation ) { + if ( $variation['name'] === $name ) { + unset( $variations[ $i ] ); + break; + } + } + // Reindex array after removing one variation. + $navigation_block_type->variations = array_values( $variations ); +} + +/** + * Returns an array of variations for the post-terms block. + * + * @return array + */ +function build_post_term_block_variations() { // This will only handle taxonomies registered until this point (init on priority 9). // See action hooks below for other taxonomies. // See https://github.com/WordPress/gutenberg/issues/52569 for details. @@ -107,7 +157,7 @@ function register_block_core_post_terms() { // Create and register the eligible taxonomies variations. foreach ( $taxonomies as $taxonomy ) { - $variation = block_core_post_terms_build_variation_for_post_terms( $taxonomy ); + $variation = build_variation_for_post_terms( $taxonomy ); // Set the category variation as the default one. if ( 'category' === $taxonomy->name ) { $variation['isDefault'] = true; @@ -150,18 +200,10 @@ function register_block_core_post_terms() { * @return void */ function block_core_post_terms_register_taxonomy_variation( $taxonomy, $object_type, $args ) { - if ( isset( $args['publicly_queryable'] ) && $args['publicly_queryable'] ) { - $variation = block_core_post_terms_build_variation_for_post_terms( (object) $args ); - // Directly set the variations on the registered block type - // because there's no server side registration for variations (see #47170). - $post_terms_block_type = WP_Block_Type_Registry::get_instance()->get_registered( 'core/post-terms' ); - // If the block is not registered yet, bail early. - // Variation will be registered in register_block_core_post_terms then. - if ( ! $post_terms_block_type ) { - return; - } - - $post_terms_block_type->variations[] = $variation; + if ( isset( $args['publicly_queryable'] ) && $args['publicly_queryable'] + && isset( $args['show_in_rest'] ) && $args['show_in_rest'] ) { + $variation = build_variation_for_post_terms( (object) $args ); + block_core_post_terms_register_variation( $variation ); } } @@ -172,20 +214,5 @@ function block_core_post_terms_register_taxonomy_variation( $taxonomy, $object_t * @return void */ function block_core_post_terms_unregister_taxonomy_variation( $taxonomy ) { - // Directly get the variations from the registered block type - // because there's no server side (un)registration for variations (see #47170). - $post_terms_block_type = WP_Block_Type_Registry::get_instance()->get_registered( 'core/post-terms' ); - // If the block is not registered (yet), there's no need to remove a variation. - if ( ! $post_terms_block_type || empty( $post_terms_block_type->variations ) ) { - return; - } - // Search for the variation and remove it from the array. - foreach ( $post_terms_block_type->variations as $i => $variation ) { - if ( $variation['name'] === $taxonomy ) { - unset( $post_terms_block_type->variations[ $i ] ); - break; - } - } - // Reindex array after removing one variation. - $post_terms_block_type->variations = array_values( $post_terms_block_type->variations ); + block_core_post_terms_unregister_variation( $taxonomy ); } diff --git a/phpcs.xml.dist b/phpcs.xml.dist index ecc800f9892416..29411a650882ea 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -127,6 +127,7 @@ + diff --git a/phpunit/blocks/block-post-terms-variations-test.php b/phpunit/blocks/block-post-terms-variations-test.php index dcb48fb42cb1b1..3e409059c7e352 100644 --- a/phpunit/blocks/block-post-terms-variations-test.php +++ b/phpunit/blocks/block-post-terms-variations-test.php @@ -18,9 +18,11 @@ public function set_up() { 'book_type', array( 'post' ), array( - 'labels' => array( + 'labels' => array( 'name' => 'Book Type', ), + 'publicly_queryable' => true, + 'show_in_rest' => true, ) ); @@ -75,9 +77,11 @@ public function test_post_terms_variations_unregister_taxonomy() { 'temp_book_type', 'custom_book', array( - 'labels' => array( + 'labels' => array( 'name' => 'Book Type', ), + 'publicly_queryable' => true, + 'show_in_rest' => true, ) ); From a448131d0dbe688a51de37d1af1cdacabee92c00 Mon Sep 17 00:00:00 2001 From: Fabian Todt Date: Mon, 29 Jan 2024 15:09:32 +0100 Subject: [PATCH 7/7] fix code style of comments --- .../block-library/src/post-terms/index.php | 58 ++++++++++++------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/packages/block-library/src/post-terms/index.php b/packages/block-library/src/post-terms/index.php index 35a65a100c6dd9..47141fc934d0a1 100644 --- a/packages/block-library/src/post-terms/index.php +++ b/packages/block-library/src/post-terms/index.php @@ -85,17 +85,22 @@ function build_variation_for_post_terms( $taxonomy ) { } /** - * Register a variation for a taxonomy for the post-terms block. + * Registers a variation for a taxonomy for the post-terms block. + * + * @since 6.X.Y * * @param array $variation Variation array from build_variation_for_post_terms. - * @return void */ function block_core_post_terms_register_variation( $variation ) { - // Directly set the variations on the registered block type - // because there's no server side registration for variations (see #47170). + /* + * Directly set the variations on the registered block type + * because there's no server side registration for variations (see #47170). + */ $navigation_block_type = WP_Block_Type_Registry::get_instance()->get_registered( 'core/post-terms' ); - // If the block is not registered yet, bail early. - // Variation will be registered in register_block_core_post_terms then. + /* + * If the block is not registered yet, bail early. + * Variation will be registered in register_block_core_post_terms then. + */ if ( ! $navigation_block_type ) { return; } @@ -107,14 +112,17 @@ function block_core_post_terms_register_variation( $variation ) { } /** - * Unregister a variation for a taxonomy for the post-terms block. + * Unregisters a variation for a taxonomy for the post-terms block. + * + * @since 6.X.Y * * @param string $name Name of the taxonomy (which was used as variation name). - * @return void */ function block_core_post_terms_unregister_variation( $name ) { - // Directly get the variations from the registered block type - // because there's no server side (un)registration for variations (see #47170). + /* + * Directly get the variations from the registered block type + * because there's no server side (un)registration for variations (see #47170). + */ $navigation_block_type = WP_Block_Type_Registry::get_instance()->get_registered( 'core/post-terms' ); // If the block is not registered (yet), there's no need to remove a variation. if ( ! $navigation_block_type || empty( $navigation_block_type->variations ) ) { @@ -135,12 +143,16 @@ function block_core_post_terms_unregister_variation( $name ) { /** * Returns an array of variations for the post-terms block. * + * @since 6.5.0 + * * @return array */ function build_post_term_block_variations() { - // This will only handle taxonomies registered until this point (init on priority 9). - // See action hooks below for other taxonomies. - // See https://github.com/WordPress/gutenberg/issues/52569 for details. + /* + * This will only handle taxonomies registered until this point (init on priority 9). + * See action hooks below for other taxonomies. + * See https://github.com/WordPress/gutenberg/issues/52569 for details. + */ $taxonomies = get_taxonomies( array( 'publicly_queryable' => true, @@ -149,9 +161,10 @@ function build_post_term_block_variations() { 'objects' ); - // Split the available taxonomies to `built_in` and custom ones, - // in order to prioritize the `built_in` taxonomies at the - // search results. + /* Split the available taxonomies to `built_in` and custom ones, + * in order to prioritize the `built_in` taxonomies at the + * search results. + */ $built_ins = array(); $custom_variations = array(); @@ -185,15 +198,19 @@ function register_block_core_post_terms() { ); } add_action( 'init', 'register_block_core_post_terms' ); -// Register actions for all taxonomies, to add variations when they are registered. -// All taxonomies registered before register_block_core_post_terms, will be handled by that function. +/* + * Register actions for all taxonomies, to add variations when they are registered. + * All taxonomies registered before register_block_core_post_terms, will be handled by that function. + */ add_action( 'registered_taxonomy', 'block_core_post_terms_register_taxonomy_variation', 10, 3 ); add_action( 'unregistered_taxonomy', 'block_core_post_terms_unregister_taxonomy_variation', 10, 3 ); /** - * Register a custom taxonomy variation for post terms on taxonomy registration + * Registers a custom taxonomy variation for the post-terms block on taxonomy registration * Handles all taxonomies registered after the block is registered in register_block_core_post_terms * + * @since 6.X.Y + * * @param string $taxonomy Taxonomy slug. * @param array|string $object_type Object type or array of object types. * @param array $args Array of taxonomy registration arguments. @@ -210,8 +227,9 @@ function block_core_post_terms_register_taxonomy_variation( $taxonomy, $object_t /** * Unregisters a custom taxonomy variation for post terms block on taxonomy unregistration. * + * @since 6.X.Y + * * @param string $taxonomy The taxonomy name passed from unregistered_taxonomy action hook. - * @return void */ function block_core_post_terms_unregister_taxonomy_variation( $taxonomy ) { block_core_post_terms_unregister_variation( $taxonomy );