-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Globals Styles Endpoint: Declare edit_css capability in links #3889
Globals Styles Endpoint: Declare edit_css capability in links #3889
Conversation
public function test_assign_edit_css_action_admin() { | ||
wp_set_current_user( self::$admin_id ); | ||
|
||
$request = new WP_REST_Request( 'GET', '/wp/v2/global-styles/' . self::$global_styles_id ); | ||
$request->set_param( 'context', 'edit' ); | ||
$response = rest_do_request( $request ); | ||
$links = $response->get_links(); | ||
|
||
// Admins can only edit css on single site. | ||
if ( is_multisite() ) { | ||
$this->assertArrayNotHasKey( 'https://api.w.org/action-edit-css', $links ); | ||
} else { | ||
$this->assertArrayHasKey( 'https://api.w.org/action-edit-css', $links ); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used the post-controller tests as a blueprint here https://github.com/WordPress/wordpress-develop/blob/6.1/tests/phpunit/tests/rest-api/rest-posts-controller.php#L4903-L4918.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job @Mamaduka 👏
if ( current_user_can( 'edit_css' ) ) { | ||
$rels[] = 'https://api.w.org/action-edit-css'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an unanswered question from the Gutenberg PR
I couldn't find documentation on how these URLs are generated/created. So I need to double-check if
https://api.w.org/action-edit-css
is the correct format.
Pinging @TimothyBJacobs @spacedmonkey for review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All similar action URLs lead to a 404 page - https://api.wordpress.org/action-unfiltered-html
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TimothyBJacobs, @spacedmonkey, can you confirm that it's okay to use this URL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for missing this the first time round. The URLs don't actually point anywhere. That URL is fine to use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @TimothyBJacobs!
Currently reviewing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Confirmed this patch has the REST PHP code changes from the GB PR ✅
- Timothy confirmed the URL is okay ✅
- Tests included ✅
Ready for commit 👍
Committed via https://core.trac.wordpress.org/changeset/55177. |
Trac ticket: https://core.trac.wordpress.org/ticket/57526
Related Gutenberg PR: WordPress/gutenberg#46815
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.