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

Globals Styles Endpoint: Declare edit_css capability in links #3889

Conversation

Mamaduka
Copy link
Member

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.

Comment on lines +520 to +534
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 );
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job @Mamaduka 👏

@Mamaduka
Copy link
Member Author

cc @hellofromtonya

Comment on lines +445 to +447
if ( current_user_can( 'edit_css' ) ) {
$rels[] = 'https://api.w.org/action-edit-css';
}
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @TimothyBJacobs!

@hellofromtonya
Copy link
Contributor

Currently reviewing.

Copy link
Contributor

@hellofromtonya hellofromtonya left a 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 👍

@hellofromtonya
Copy link
Contributor

@Mamaduka Mamaduka deleted the backport/global-styles-controller-actions branch May 9, 2023 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants