Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code quality improvements for the global styles endpoint #36071

Merged
merged 1 commit into from
Oct 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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