From ae5034ebc9586570eaf08d99d9544eac407c3f01 Mon Sep 17 00:00:00 2001 From: Jorge Date: Mon, 3 May 2021 17:51:43 +0100 Subject: [PATCH] Update: Use wp_theme taxonomy for wp_global_styles cpt. --- lib/class-wp-theme-json-resolver.php | 13 ++++++++++--- lib/full-site-editing/templates.php | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/class-wp-theme-json-resolver.php b/lib/class-wp-theme-json-resolver.php index 86c3708b111032..060c87dc0b8e25 100644 --- a/lib/class-wp-theme-json-resolver.php +++ b/lib/class-wp-theme-json-resolver.php @@ -307,7 +307,6 @@ public static function get_theme_data( $theme_support_data = array() ) { private static function get_user_data_from_custom_post_type( $should_create_cpt = false, $post_status_filter = array( 'publish' ) ) { $user_cpt = array(); $post_type_filter = 'wp_global_styles'; - $post_name_filter = 'wp-global-styles-' . urlencode( wp_get_theme()->get_stylesheet() ); $recent_posts = wp_get_recent_posts( array( 'numberposts' => 1, @@ -315,7 +314,13 @@ private static function get_user_data_from_custom_post_type( $should_create_cpt 'order' => 'desc', 'post_type' => $post_type_filter, 'post_status' => $post_status_filter, - 'name' => $post_name_filter, + 'tax_query' => array( + array( + 'taxonomy' => 'wp_theme', + 'field' => 'name', + 'terms' => wp_get_theme()->get_stylesheet(), + ), + ), ) ); @@ -328,7 +333,9 @@ private static function get_user_data_from_custom_post_type( $should_create_cpt 'post_status' => 'publish', 'post_title' => __( 'Custom Styles', 'default' ), 'post_type' => $post_type_filter, - 'post_name' => $post_name_filter, + 'tax_input' => array( + 'wp_theme' => array( wp_get_theme()->get_stylesheet() ), + ), ), true ); diff --git a/lib/full-site-editing/templates.php b/lib/full-site-editing/templates.php index fd571fbef14f63..98591e680177f8 100644 --- a/lib/full-site-editing/templates.php +++ b/lib/full-site-editing/templates.php @@ -90,7 +90,7 @@ function gutenberg_register_wp_theme_taxonomy() { register_taxonomy( 'wp_theme', - array( 'wp_template', 'wp_template_part' ), + array( 'wp_template', 'wp_template_part', 'wp_global_styles' ), array( 'public' => false, 'hierarchical' => false,