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 3, 2021
1 parent ab2a61a commit ae5034e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions lib/class-wp-theme-json-resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,15 +307,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 @@ -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
);
Expand Down
2 changes: 1 addition & 1 deletion lib/full-site-editing/templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ae5034e

Please sign in to comment.