Skip to content

Commit

Permalink
Code quality improvements for the global styles endpoint (#36071)
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad authored Oct 29, 2021
1 parent 88164eb commit 2d00327
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
3 changes: 1 addition & 2 deletions lib/class-wp-theme-json-resolver-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,7 @@ public static function register_user_custom_post_type() {
'description' => 'CPT to store user design tokens',
'public' => false,
'show_ui' => false,
'show_in_rest' => true,
'rest_base' => '__experimental/global-styles',
'show_in_rest' => false,
'capabilities' => array(
'read' => 'edit_theme_options',
'create_posts' => 'edit_theme_options',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@
* Base Global Styles REST API Controller.
*/
class Gutenberg_REST_Global_Styles_Controller extends WP_REST_Controller {
/**
* Post type.
*
* @var string
*/
protected $post_type;

/**
* Constructor.
*/
Expand Down
6 changes: 3 additions & 3 deletions lib/compat/wordpress-5.9/rest-active-global-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ function gutenberg_add_active_global_styles_link( $response, $theme ) {
// This creates a record for the current theme if not existant.
$id = WP_Theme_JSON_Resolver_Gutenberg::get_user_custom_post_type_id();
} else {

$wp_query_args = array(
'post_status' => array( 'publish' ),
'post_status' => 'publish',
'post_type' => 'wp_global_styles',
'posts_per_page' => 1,
'no_found_rows' => true,
'fields' => 'ids',
'tax_query' => array(
array(
'taxonomy' => 'wp_theme',
Expand All @@ -31,7 +31,7 @@ function gutenberg_add_active_global_styles_link( $response, $theme ) {
),
);
$global_styles_query = new WP_Query( $wp_query_args );
$id = count( $global_styles_query->posts ) ? $global_styles_query->posts[0]->ID : null;
$id = ! empty( $global_styles_query->posts ) ? array_shift( $global_styles_query->posts ) : null;
}

if ( $id ) {
Expand Down

0 comments on commit 2d00327

Please sign in to comment.