10up / restricted-site-access

Limit access to visitors who are logged in or allowed by IP addresses. Includes many options for handling blocked visitors.
http://10up.com/plugins/restricted-site-access-wordpress/
GNU General Public License v2.0
231 stars 47 forks source link

Add support for the WordPress.org plugin preview #298

Closed dkotter closed 10 months ago

dkotter commented 10 months ago

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. Sets up some default options
  5. Sends users to the Reading settings page

In order to actually test the restriction, you'll have to log out and then on the login screen, click on the Go to my WordPress website. At this point you should see the restriction message.

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 won't work though until https://github.com/10up/action-wordpress-plugin-asset-update/pull/54 is released.

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-reading.php%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%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%22installPlugin%22,%20%22pluginZipFile%22:%20{%20%22resource%22:%20%22wordpress.org\/plugins%22,%20%22slug%22:%20%22restricted-site-access%22%20},%20%22options%22:%20{%20%22activate%22:%20true%20}%20},%20{%20%22step%22:%20%22setSiteOptions%22,%20%22options%22:%20{%20%22rsa_options%22:%20{%20%22approach%22:%203,%20%22allowed%22:%20[%20%22127.0.0.1%22%20],%20%22comment%22:%20[%20%22Example%20of%20an%20allowed%20IP%20address%22%20]%20},%20%22rsa_activation_version%22:%20%227.5.0%22%20}%20}%20]%20}

Changelog Entry

Added - Support for the WordPress.org plugin preview

Credits

Props @dkotter

Checklist: