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 #158

Merged
merged 1 commit into from
Dec 14, 2023

Conversation

dkotter
Copy link
Collaborator

@dkotter dkotter commented Dec 13, 2023

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. Sets up pretty permalinks
  4. Installs and activates the plugin
  5. Runs some custom PHP that will add a sample ads.txt file and app-ads.txt file
  6. Sends the user to the ads.txt settings page

Note that this PR is targeted to trunk as the hope is we can take advantage of our Plugin Asset Update Action to deploy these changes without having to push out a new release. This new blueprint file needs to live within the assets directory in the svn repo, which is the same directory that Action will send changes to.

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/#{%22$schema%22:%22https://playground.wordpress.net/blueprint-schema.json%22,%22landingPage%22:%22/wp-admin/options-general.php?page=adstxt-settings%22,%22preferredVersions%22:{%22php%22:%227.4%22,%22wp%22:%22latest%22},%22phpExtensionBundles%22:[%22kitchen-sink%22],%22steps%22:[{%22step%22:%22login%22,%22username%22:%22admin%22,%22password%22:%22password%22},{%22step%22:%22setSiteOptions%22,%22options%22:{%22permalink_structure%22:%22/%25postname%25/%22}},{%22step%22:%22installPlugin%22,%22pluginZipFile%22:{%22resource%22:%22wordpress.org/plugins%22,%22slug%22:%22ads-txt%22},%22options%22:{%22activate%22:true}},{%22step%22:%22runPHP%22,%22code%22:%22%3C?php%20require_once%20'wordpress/wp-load.php';%20$adstxt_id%20=%20wp_insert_post(%20array(%20'post_title'%20=%3E%20'Ads.txt',%20'post_content'%20=%3E%20'#%20Example%20information\[email protected]\n\n#%20Example%20record\ngoogle.com,%20pub-1234567890,%20DIRECT,%20f08c47fec0942fa0',%20'post_status'%20=%3E%20'publish',%20'post_type'%20=%3E%20'adstxt'%20)%20);%20$app_adstxt_id%20=%20wp_insert_post(%20array(%20'post_title'%20=%3E%20'App-ads.txt',%20'post_content'%20=%3E%20'#%20Example%20information\[email protected]\n\n#%20Example%20record\ngoogle.com,%20pub-1234567890,%20DIRECT,%20f08c47fec0942fa0',%20'post_status'%20=%3E%20'publish',%20'post_type'%20=%3E%20'app-adstxt'%20)%20);%20if%20(%20!%20$adstxt_id%20instanceof%20WP_Error%20)%20{%20update_option(%20'adstxt_post',%20(int)%20$adstxt_id%20);%20}%20if%20(%20!%20$app_adstxt_id%20instanceof%20WP_Error%20)%20{%20update_option(%20'app_adstxt_post',%20(int)%20$app_adstxt_id%20);%20}%22}]}

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 self-assigned this Dec 13, 2023
@dkotter dkotter requested a review from jeffpaul as a code owner December 13, 2023 22:49
@dkotter
Copy link
Collaborator Author

dkotter commented Dec 13, 2023

One big thing to note here is that the WP Playground doesn't seem to support pretty permalinks yet (see WordPress/playground-tools#53) which this plugin requires to fully work.

So right now you can see the settings page with sample content and can modify that content. But if you try and view the ads.txt file itself, it won't work. This may be a big enough issue that we don't want to enable previews yet but figured worth capturing the needed code for now.

@jeffpaul
Copy link
Member

Perhaps that's still fine @dkotter as folks can at least see the interaction and revisions for ads/app-ads.txt files in the interim?

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.

:shipit:

@jeffpaul jeffpaul added this to the 1.5.0 milestone Dec 13, 2023
@dkotter dkotter merged commit be7c4df into trunk Dec 14, 2023
1 check passed
@dkotter dkotter deleted the feature/plugin-preview branch December 14, 2023 15:35
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.

2 participants