Skip to content

Commit

Permalink
fix(urlbox-screenshots): add json encoding to proxy test request (#9)
Browse files Browse the repository at this point in the history
refactor(urlbox-screenshots): update dockblocks to be more informative

Feat(wp-env): Introduce wp-env config and instructions in readme.md

Refactor(urlbox-screenshots): Decouple POST /sync method from proxy logic

Refactor(urlbox-screenshots): Introduce constants in plugin for reusability/consistency

Refactor(urlbox-screenshots): Ensure proxy test method stops script on invalid nonce or proxy setting

Refactor(urlbox-screenshots): Add more detailed dockblocking

refactor(readme): Update readme with wp-env instructions

Refactor(urlbox-screenshots): Check if proxy keys are set before access

Refactor(urlbox-screenshots): Bump versioning up to latest release and minimum wp version, adding to changelog

fix(comments): typos
  • Loading branch information
AJCJ1 authored Aug 1, 2024
1 parent cfa4686 commit 1b42773
Show file tree
Hide file tree
Showing 4 changed files with 365 additions and 106 deletions.
10 changes: 10 additions & 0 deletions .wp-env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"core": null,
"plugins": [ "." ],
"phpVersion": "8.0",
"config": {
"WP_DEBUG": true,
"WP_DEBUG_LOG": true,
"WP_DEBUG_DISPLAY": true
}
}
34 changes: 30 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ See the plugin settings page for all possible options

## Changelog

### 1.6.1

Performs a refactor of the plugin, fixing a bug in the proxy logic, adding more documentation to docblocks, improving security issues, and decoupling proxy logic into a specific test method for the proxy connection and a generalised POST /sync method.

### 1.6.0

Introduce proxy logic, so users can make urlbox screenshot requests via their proxy which is set in the plugin settings.
Expand Down Expand Up @@ -112,18 +116,40 @@ Fixed minor bugs and tested with Wordpress 5.7-beta

Initial Release!

## Releasing/Updating the Plugin on Wordpress
## Testing

[URLBox Screenshots Wordpress Plugin Homepage](https://wordpress.org/plugins/urlbox-screenshots/#developers)
There are two ways to test the plugin easily, one with the wordpress playground, and the other using wp-env.

To install wp env make sure you have Node installed and Docker. Make sure docker is running!

Install: `npm -g i @wordpress/env`

wp-env uses a config file held in this directory (wp-env.json). Make sure you're in this directory in your terminal, then run:

`WP_ENV_PORT=3333 wp-env start`

### Testing
This will set the exposed port to 3333 instead of 8888 which some people often have in use. You can change this port to whatever you wish that is unused.

You can test the plugin by zipping it from the root file, then importing the zipped file using a locally running Wordpress instance, or using this playground:
You can change wordpress and php versions by changing the wp-env.json:

```JSON
"core": "Wordpress/WordPress#6.0",
"phpVersion": "8.0",
```

Will change to wordpress version 6.0 and PHP 8.0 on rerunning wp-env start.

You can also test the plugin by zipping it from the root file, then importing the zipped file in this playground:

'''https://playground.wordpress.net/?storage=browser&php=8.0&wp=6.5&networking=yes'''

Ensure that you're on at least PHP 8, Wordpress 6.5 and you have networking enabled.

## Releasing/Updating the Plugin on Wordpress

[URLBox Screenshots Wordpress Plugin Homepage](https://wordpress.org/plugins/urlbox-screenshots/#developers)


### Overview

By creating a new tagged release with the zipped repo, GH actions should automatically update the wordpress.org repository.
Expand Down
18 changes: 12 additions & 6 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Contributors: Chris Roebuck, Ankur Gurha, James Ogilvie, Arnold Cubici-Jones
Author: Urlbox
Tags: screenshot,screenshots,puppeteer,playwright,url to png
Requires at least: 3.3
Tested up to: 6.5
Stable tag: 1.6.0
Requires at least: 6.0
Tested up to: 6.6.1
Stable tag: 1.6.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -16,6 +16,8 @@ This plugin uses the Urlbox API to generate website screenshots and display them

**How to use the plugin**

When running Wordpress locally or in a containerised environment, we recommend you use at least Wordpress version 6.0 and PHP 8.0.

1. First activate the plugin and fill in your Urlbox.com API Key and Secret in the settings page.

2. (Optional) You can set default options for your screenshots such as width, height, and thumbnail width on the plugin settings page.
Expand All @@ -40,8 +42,8 @@ The plugin wraps the `<img>` element inside a `<figure>` element. You can set th

== Installation ==

1. Upload the Urlbox plugin directory to the `/wp-content/plugins/urlbox` directory or install using the WordPress plugin installer
2. Activate the plugin through the **Plugins** menu in WordPress
1. Upload the Urlbox plugin directory to the `/wp-content/plugins/urlbox` directory or install using the Wordpress plugin installer
2. Activate the plugin through the **Plugins** menu in Wordpress
3. Edit default settings as necessary using **Urlbox Options**
4. Create a new page or post, or edit an existing one
5. Insert your shortcode using the Shortcode block
Expand All @@ -62,10 +64,14 @@ See <https://urlbox.com/docs/options> for default values

== Known Bugs ==

* None at this time
1.6.0 - Bug in proxy logic. Testing one's proxy connection in the plugin's settings will not work due to an 'Invalid JSON' error, because of a lack of JSON encoding. This error does not display in the Wordpress playground, but will display in any dockerised/live environment. Action taken was to fix the bug and release 1.6.1, and introduce a dockerised test/development environment for future coverage before releases.

== Changelog ==

= 1.6.1 =

Performs a refactor of the plugin, fixing a bug in the proxy logic, adding more documentation to docblocks, improving security issues, and decoupling proxy logic into a specific test method for the proxy connection and a generalised POST /sync method.

= 1.6.0 =

Introduce proxy logic, so users can make urlbox screenshot requests via their proxy which is set in the plugin settings.
Expand Down
Loading

0 comments on commit 1b42773

Please sign in to comment.