Skip to content

Commit

Permalink
Update: Use wp_theme taxonomy for wp_global_styles cpt.
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta committed May 7, 2021
1 parent d312574 commit 9dade09
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 11 additions & 3 deletions lib/class-wp-theme-json-resolver.php
Expand Up @@ -311,15 +311,20 @@ 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,
'orderby' => 'date',
'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(),
),
),
)
);

Expand All @@ -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
);
Expand Down
4 changes: 2 additions & 2 deletions lib/full-site-editing/templates.php
Expand Up @@ -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,
Expand Down

0 comments on commit 9dade09

Please sign in to comment.