From 94d2e5206f38b6c5c3fbfccd90af2af306802535 Mon Sep 17 00:00:00 2001 From: Glen Davies Date: Thu, 17 Aug 2023 14:53:39 +1200 Subject: [PATCH 1/6] Add custom patterns taxonomy --- lib/compat/wordpress-6.4/block-patterns.php | 35 +++++++++++++++++++++ lib/load.php | 1 + 2 files changed, 36 insertions(+) create mode 100644 lib/compat/wordpress-6.4/block-patterns.php diff --git a/lib/compat/wordpress-6.4/block-patterns.php b/lib/compat/wordpress-6.4/block-patterns.php new file mode 100644 index 00000000000000..10dfea83ea978e --- /dev/null +++ b/lib/compat/wordpress-6.4/block-patterns.php @@ -0,0 +1,35 @@ += 6.4. + * + * @see https://github.com/WordPress/gutenberg/pull/51144 + * + * @return void + */ +function gutenberg_register_taxonomy_patterns() { + $labels = array( + 'name' => _x( 'Pattern Categories', 'taxonomy general name' ), + 'singular_name' => _x( 'Pattern Category', 'taxonomy singular name' ), + ); + $args = array( + 'hierarchical' => false, + 'labels' => $labels, + 'show_ui' => true, + 'show_in_menu' => false, + 'show_in_nav_menus' => false, + 'show_admin_column' => true, + 'query_var' => true, + 'show_in_rest' => true, + 'rewrite' => array( 'slug' => 'wp_pattern_custom_category' ), + ); + register_taxonomy( 'wp_pattern_custom_category', array( 'wp_block' ), $args ); +} +add_action( 'init', 'gutenberg_register_taxonomy_patterns' ); diff --git a/lib/load.php b/lib/load.php index ec3cddf56d257f..03416c87887694 100644 --- a/lib/load.php +++ b/lib/load.php @@ -121,6 +121,7 @@ function gutenberg_is_experiment_enabled( $name ) { // WordPress 6.4 compat. require __DIR__ . '/compat/wordpress-6.4/blocks.php'; +require __DIR__ . '/compat/wordpress-6.4/block-patterns.php'; // Experimental features. require __DIR__ . '/experimental/block-editor-settings-mobile.php'; From d7c1065bcbf6bfe8e8159bb8e88093d16d9240ae Mon Sep 17 00:00:00 2001 From: Glen Davies Date: Mon, 31 Jul 2023 15:56:39 +1200 Subject: [PATCH 2/6] Update pull request number --- lib/compat/wordpress-6.4/block-patterns.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/compat/wordpress-6.4/block-patterns.php b/lib/compat/wordpress-6.4/block-patterns.php index 10dfea83ea978e..18d5efc216da6d 100644 --- a/lib/compat/wordpress-6.4/block-patterns.php +++ b/lib/compat/wordpress-6.4/block-patterns.php @@ -10,7 +10,7 @@ * * Note: This should be removed when the minimum required WP version is >= 6.4. * - * @see https://github.com/WordPress/gutenberg/pull/51144 + * @see https://github.com/WordPress/gutenberg/pull/53163 * * @return void */ From 28d1fcf486b465e389818c37bd71eb16e1bcf4f8 Mon Sep 17 00:00:00 2001 From: Glen Davies Date: Tue, 1 Aug 2023 09:38:12 +1200 Subject: [PATCH 3/6] Drop custom from the taxonomy name --- lib/compat/wordpress-6.4/block-patterns.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/compat/wordpress-6.4/block-patterns.php b/lib/compat/wordpress-6.4/block-patterns.php index 18d5efc216da6d..01c1573729f7e7 100644 --- a/lib/compat/wordpress-6.4/block-patterns.php +++ b/lib/compat/wordpress-6.4/block-patterns.php @@ -28,8 +28,8 @@ function gutenberg_register_taxonomy_patterns() { 'show_admin_column' => true, 'query_var' => true, 'show_in_rest' => true, - 'rewrite' => array( 'slug' => 'wp_pattern_custom_category' ), + 'rewrite' => array( 'slug' => 'wp_pattern_category' ), ); - register_taxonomy( 'wp_pattern_custom_category', array( 'wp_block' ), $args ); + register_taxonomy( 'wp_pattern_category', array( 'wp_block' ), $args ); } add_action( 'init', 'gutenberg_register_taxonomy_patterns' ); From 7d2eae10e2d6c50f470ca29bb1ac5fad5d5a9396 Mon Sep 17 00:00:00 2001 From: Glen Davies Date: Thu, 10 Aug 2023 14:22:12 +1200 Subject: [PATCH 4/6] Flag as taxonomy as builtin --- lib/compat/wordpress-6.4/block-patterns.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/compat/wordpress-6.4/block-patterns.php b/lib/compat/wordpress-6.4/block-patterns.php index 01c1573729f7e7..4ecad0ddd1f5c8 100644 --- a/lib/compat/wordpress-6.4/block-patterns.php +++ b/lib/compat/wordpress-6.4/block-patterns.php @@ -28,6 +28,7 @@ function gutenberg_register_taxonomy_patterns() { 'show_admin_column' => true, 'query_var' => true, 'show_in_rest' => true, + '_builtin' => true, 'rewrite' => array( 'slug' => 'wp_pattern_category' ), ); register_taxonomy( 'wp_pattern_category', array( 'wp_block' ), $args ); From 907e04a4171d8200e922bc50a43b9d33ce5db05b Mon Sep 17 00:00:00 2001 From: Glen Davies Date: Thu, 17 Aug 2023 17:04:50 +1200 Subject: [PATCH 5/6] Remove UI for now and only expose via rest --- lib/compat/wordpress-6.4/block-patterns.php | 28 ++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/compat/wordpress-6.4/block-patterns.php b/lib/compat/wordpress-6.4/block-patterns.php index 4ecad0ddd1f5c8..69e7c1d0eba901 100644 --- a/lib/compat/wordpress-6.4/block-patterns.php +++ b/lib/compat/wordpress-6.4/block-patterns.php @@ -15,21 +15,21 @@ * @return void */ function gutenberg_register_taxonomy_patterns() { - $labels = array( - 'name' => _x( 'Pattern Categories', 'taxonomy general name' ), - 'singular_name' => _x( 'Pattern Category', 'taxonomy singular name' ), - ); $args = array( - 'hierarchical' => false, - 'labels' => $labels, - 'show_ui' => true, - 'show_in_menu' => false, - 'show_in_nav_menus' => false, - 'show_admin_column' => true, - 'query_var' => true, - 'show_in_rest' => true, - '_builtin' => true, - 'rewrite' => array( 'slug' => 'wp_pattern_category' ), + array( + 'public' => false, + 'hierarchical' => false, + 'labels' => array( + 'name' => _x( 'Pattern Categories', 'taxonomy general name' ), + 'singular_name' => _x( 'Pattern Category', 'taxonomy singular name' ), + ), + 'query_var' => false, + 'rewrite' => false, + 'show_ui' => false, + '_builtin' => true, + 'show_in_nav_menus' => false, + 'show_in_rest' => true, + ) ); register_taxonomy( 'wp_pattern_category', array( 'wp_block' ), $args ); } From d6627662bec3b9b436fe3a107534d1f62afef61b Mon Sep 17 00:00:00 2001 From: Glen Davies Date: Thu, 17 Aug 2023 17:07:32 +1200 Subject: [PATCH 6/6] Linting fixes --- lib/compat/wordpress-6.4/block-patterns.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/compat/wordpress-6.4/block-patterns.php b/lib/compat/wordpress-6.4/block-patterns.php index 69e7c1d0eba901..aa4c5ef378bc7a 100644 --- a/lib/compat/wordpress-6.4/block-patterns.php +++ b/lib/compat/wordpress-6.4/block-patterns.php @@ -15,7 +15,7 @@ * @return void */ function gutenberg_register_taxonomy_patterns() { - $args = array( + $args = array( array( 'public' => false, 'hierarchical' => false, @@ -29,7 +29,7 @@ function gutenberg_register_taxonomy_patterns() { '_builtin' => true, 'show_in_nav_menus' => false, 'show_in_rest' => true, - ) + ), ); register_taxonomy( 'wp_pattern_category', array( 'wp_block' ), $args ); }