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

Add support for the WordPress.org plugin preview #252

Merged
merged 3 commits into from
Jan 4, 2024

Conversation

dkotter
Copy link
Collaborator

@dkotter dkotter commented Jan 3, 2024

Description of the Change

WordPress.org recently launched support for plugin previews utilizing the WordPress Playground feature. Plugins wanting to take advantage of this need to opt in by setting up a blueprint.json file that configures how the preview should load. This PR adds in that file that does the following:

  1. Sets up an environment running PHP 7.4 (our supported minimum) and the latest version of WordPress
  2. Logs into the admin
  3. Installs and activates the plugin
  4. Imports a test avatar image
  5. Sets up some default settings, including setting a default avatar
  6. Sends the user to the settings page

Note that this PR is targeted to trunk so we can take advantage of our Plugin Asset Update Action to deploy these changes without having to push out a new release. This workflow has also been fixed in this PR.

Also note once these changes are on .org, the preview button will need to be enabled in a test state. Once verified as working, we can enable it for all users.

How to test the Change

The WordPress Playground allows you to spin up a new environment directly through the URL, by going to https://playground.wordpress.net/# and pasting your JSON config after the #. In this case, the URL should be: https://playground.wordpress.net/#{%20%22$schema%22:%20%22https://playground.wordpress.net/blueprint-schema.json%22,%20%22landingPage%22:%20%22\/wp-admin\/options-discussion.php#show_avatars%22,%20%22preferredVersions%22:%20{%20%22php%22:%20%227.4%22,%20%22wp%22:%20%22latest%22%20},%20%22phpExtensionBundles%22:%20[%22kitchen-sink%22],%20%22features%22:%20{%20%22networking%22:%20true%20},%20%22steps%22:%20[%20{%20%22step%22:%20%22login%22,%20%22username%22:%20%22admin%22,%20%22password%22:%20%22password%22%20},%20{%20%22step%22:%20%22importFile%22,%20%22file%22:%20{%20%22resource%22:%20%22url%22,%20%22url%22:%20%22https:\/\/raw.githubusercontent.com\/10up\/simple-local-avatars\/073f1979d6addeb3eecd7fb8cf56efe9bcfa7007\/.wordpress-org\/blueprints\/demo-data.xml%22%20}%20},%20{%20%22step%22:%20%22installPlugin%22,%20%22pluginZipFile%22:%20{%20%22resource%22:%20%22wordpress.org\/plugins%22,%20%22slug%22:%20%22simple-local-avatars%22%20},%20%22options%22:%20{%20%22activate%22:%20true%20}%20},%20{%20%22step%22:%20%22setSiteOptions%22,%20%22options%22:%20{%20%22avatar_default%22:%20%22simple_local_avatar%22,%20%22simple_local_avatars%22:%20{%20%22caps%22:%201,%20%22only%22:%201%20},%20%22simple_local_avatar_default%22:%205%20}%20}%20]%20}

Changelog Entry

Added - Support for the WordPress.org plugin preview

Credits

Props @dkotter

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@dkotter dkotter added this to the 2.8.0 milestone Jan 3, 2024
@dkotter dkotter requested a review from jeffpaul as a code owner January 3, 2024 17:22
@dkotter dkotter self-assigned this Jan 3, 2024
@jeffpaul
Copy link
Member

jeffpaul commented Jan 3, 2024

@dkotter are we able to jump down to the Avatars heading/section on that Discussion page to get a little closer to where the SLA settings come into play?

@dkotter
Copy link
Collaborator Author

dkotter commented Jan 3, 2024

@dkotter are we able to jump down to the Avatars heading/section on that Discussion page to get a little closer to where the SLA settings come into play?

So there isn't an ID for that section to jump to. The closest is an ID for the Show Avatars checkbox. If I manually add that to the URL it does jump to that section (though it cuts off the Avatars heading) but I can't get that to work within the playground environment.

Here's a test that uses that ID in the URL: https://playground.wordpress.net/#{%20%22$schema%22:%20%22https://playground.wordpress.net/blueprint-schema.json%22,%20%22landingPage%22:%20%22\/wp-admin\/options-discussion.php#show_avatars%22,%20%22preferredVersions%22:%20{%20%22php%22:%20%227.4%22,%20%22wp%22:%20%22latest%22%20},%20%22phpExtensionBundles%22:%20[%22kitchen-sink%22],%20%22features%22:%20{%20%22networking%22:%20true%20},%20%22steps%22:%20[%20{%20%22step%22:%20%22login%22,%20%22username%22:%20%22admin%22,%20%22password%22:%20%22password%22%20},%20{%20%22step%22:%20%22importFile%22,%20%22file%22:%20{%20%22resource%22:%20%22url%22,%20%22url%22:%20%22https:\/\/raw.githubusercontent.com\/10up\/simple-local-avatars\/073f1979d6addeb3eecd7fb8cf56efe9bcfa7007\/.wordpress-org\/blueprints\/demo-data.xml%22%20}%20},%20{%20%22step%22:%20%22installPlugin%22,%20%22pluginZipFile%22:%20{%20%22resource%22:%20%22wordpress.org\/plugins%22,%20%22slug%22:%20%22simple-local-avatars%22%20},%20%22options%22:%20{%20%22activate%22:%20true%20}%20},%20{%20%22step%22:%20%22setSiteOptions%22,%20%22options%22:%20{%20%22avatar_default%22:%20%22simple_local_avatar%22,%20%22simple_local_avatars%22:%20{%20%22caps%22:%201,%20%22only%22:%201%20},%20%22simple_local_avatar_default%22:%205%20}%20}%20]%20}

It doesn't jump down to the section and if you look at the URL, the #show_avatars part is repeated twice which I think is the problem. Not sure why this gets added twice, something to do with how the playground loads that URL would be my guess.

Copy link
Member

@jeffpaul jeffpaul left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for setting this up!

@dkotter dkotter merged commit 7e99710 into trunk Jan 4, 2024
1 check passed
@dkotter dkotter deleted the feature/plugin-preview branch January 4, 2024 21:51
@faisal-alvi faisal-alvi modified the milestones: 2.8.0, 2.7.8 May 8, 2024
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