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

Global Styles: Update REST controller override method and backport changes from Core #65259

Merged
merged 11 commits into from
Sep 17, 2024
Prev Previous commit
Complete making Gutenberg global styles controller match core
aaronrobertshaw committed Sep 16, 2024
commit 2e75d56ff8e5cd3845b219c1b14ca66b044d2e15
29 changes: 2 additions & 27 deletions lib/class-wp-rest-global-styles-controller-gutenberg.php
Original file line number Diff line number Diff line change
@@ -59,6 +59,7 @@ public function register_routes() {
'type' => 'string',
),
),
'allow_batch' => $this->allow_batch,
),
),
/*
@@ -93,6 +94,7 @@ public function register_routes() {
'sanitize_callback' => array( $this, '_sanitize_global_styles_callback' ),
),
),
'allow_batch' => $this->allow_batch,
),
),
/*
@@ -248,18 +250,6 @@ public function update_item_permissions_check( $request ) {
return true;
}

/**
* Checks if a global style can be edited.
*
* @since 5.9.0
*
* @param WP_Post $post Post object.
* @return bool Whether the post can be edited.
*/
protected function check_update_permission( $post ) {
return current_user_can( 'edit_post', $post->ID );
}

/**
* Prepares a single global styles config for update.
*
@@ -467,21 +457,6 @@ protected function get_available_actions( $post, $request ) { // phpcs:ignore V
return $rels;
}

/**
* Overwrites the default protected title format.
*
* By default, WordPress will show password protected posts with a title of
* "Protected: %s", as the REST API communicates the protected status of a post
* in a machine readable format, we remove the "Protected: " prefix.
*
* @since 5.9.0
*
* @return string Protected title format.
*/
public function protected_title_format() {
return '%s';
}

/**
* Retrieves the query params for the global styles collection.
*