Skip to content

Conversation

@ramonjd
Copy link
Member

@ramonjd ramonjd commented May 18, 2024

This change:

  • extends WP_REST_Global_Styles_Revisions_Controller with WP_REST_Revisions_Controller
  • extends WP_REST_Global_Styles_Controller with WP_REST_Posts_Controller

As part of this work, the PR also:

  • Removes shared public methods
  • Updates schema to use parent and parent controller's properties. Unsets unnecessary properties.
  • Updates relevant tests. Deletes dupes.

Testing

Head over to the site editor, make a few changes to global styles.

2024-05-18.09.57.01.mp4
  1. Ensure that the revisions appear in the global styles revisions panel.
  2. Check that you can apply them to the editor canvas

You can test the responses in the editor as well by using the API in the browser console.

// Get all post types and check that `wp_global_styles` post type does not support `autosave`
const postTypes = await wp.data.resolveSelect( 'core' ).getPostTypes();
postTypes.find( item => item.slug === 'wp_global_styles' ).supports // {title: true, editor: true, revisions: true}

// Get user global styles
await wp.data.resolveSelect( 'core' ).getEntityRecord( 'root', 'globalStyles', await wp.data.resolveSelect( 'core' ).__experimentalGetCurrentGlobalStylesId() )

// Get global styles items (variations)
await wp.data.resolveSelect( 'core' ).__experimentalGetCurrentThemeGlobalStylesVariations()

// Get all revisions.
await wp.data.resolveSelect( 'core' ).getRevisions( 'root', 'globalStyles', await wp.data.resolveSelect( 'core' ).__experimentalGetCurrentGlobalStylesId() ) 

// Get a single revision, where <REVISION_ID> is the id of the single revision.
await wp.data.resolveSelect( 'core' ).getRevision( 'root', 'globalStyles', await wp.data.resolveSelect( 'core' ).__experimentalGetCurrentGlobalStylesId(), <REVISION_ID> ) 

Trac ticket: https://core.trac.wordpress.org/ticket/60131

@github-actions
Copy link

github-actions bot commented May 18, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @jonnynews.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

Core Committers: Use this line as a base for the props when committing in SVN:

Props ramonopoly, spacedmonkey, swissspidy.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@ramonjd
Copy link
Member Author

ramonjd commented May 20, 2024

Closing in favour of #6105

@ramonjd ramonjd closed this May 20, 2024
@ramonjd ramonjd deleted the update/global-styles-revision-extends-revisions-controller-6-6 branch May 20, 2024 21:54
@ramonjd ramonjd restored the update/global-styles-revision-extends-revisions-controller-6-6 branch May 28, 2024 06:37
ramonjd and others added 22 commits May 28, 2024 16:39
WP_REST_Global_Styles_Revisions_Controller extends WP_REST_Controller
…-revisions-controller.php

Co-authored-by: Mukesh Panchal <[email protected]>
Excluding order and order by from the collection query params

Comment
Updating generated API file
removing __construct, get_item and update_item in favour of the parent class methods

Add $allow_batch property, setting it to false
This commit adds the 'allow_batch' option to several API endpoints in the WordPress API generated tests fixture. The 'allow_batch' option has been set to false for version 1, effectively disabling batch requests for these endpoints, as a safety measure.
Bumped version from 6.5 to 6.6 in annotations
@ramonjd ramonjd reopened this May 28, 2024
@ramonjd ramonjd force-pushed the update/global-styles-revision-extends-revisions-controller-6-6 branch from 0fa1286 to 18ef3eb Compare May 28, 2024 06:42
@swissspidy
Copy link
Member

Committed in https://core.trac.wordpress.org/changeset/58225

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.

4 participants