diff --git a/lib/class-wp-theme-json-resolver.php b/lib/class-wp-theme-json-resolver.php index 1eb2521e795a4..05510589920a9 100644 --- a/lib/class-wp-theme-json-resolver.php +++ b/lib/class-wp-theme-json-resolver.php @@ -311,7 +311,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, @@ -319,7 +318,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(), + ), + ), ) ); @@ -332,7 +337,10 @@ 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, + 'post_name' => 'wp-global-styles-' . urlencode( wp_get_theme()->get_stylesheet() ), + '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 fd571fbef14f6..08048b5b4b06e 100644 --- a/lib/full-site-editing/templates.php +++ b/lib/full-site-editing/templates.php @@ -84,13 +84,13 @@ function gutenberg_register_template_post_type() { * Registers block editor 'wp_theme' taxonomy. */ function gutenberg_register_wp_theme_taxonomy() { - if ( ! gutenberg_supports_block_templates() ) { + if ( ! gutenberg_supports_block_templates() && ! WP_Theme_JSON_Resolver::theme_has_support() ) { return; } register_taxonomy( 'wp_theme', - array( 'wp_template', 'wp_template_part' ), + array( 'wp_template', 'wp_template_part', 'wp_global_styles' ), array( 'public' => false, 'hierarchical' => false,