10up / safe-svg

Enable SVG uploads and sanitize them to stop XML/SVG vulnerabilities in your WordPress website.
https://wordpress.org/plugins/safe-svg/
GNU General Public License v2.0
263 stars 31 forks source link

Add another dependency to our optimizer script #187

Closed dkotter closed 5 months ago

dkotter commented 5 months ago

Description of the Change

As described in #182, when using the optimizer feature and running in the Classic Editor, there's a chance for JS errors that can cause conflicts with other features (in this case Yoast SEO).

The problem is we call the method isSavingPost which doesn't natively exist in the Classic Editor. This PR fixes this by adding wp-editor as a dependency to our optimizer script.

Closes #182

How to test the Change

  1. In a clean environment, install the Classic Editor plugin, Yoast SEO and Safe SVG
  2. Add the following code to turn on the optimizer feature: add_filter( 'safe_svg_optimizer_enabled', '__return_true' );
  3. Create a new classic post and you should see a JS error in the console. In addition, the Yoast SEO panel won't load properly
  4. Checkout this PR and ensure that error goes away
  5. If desired, deactivate the Classic Editor plugin and test that things still work properly in the Block Editor

Changelog Entry

Fixed - Ensure we don't throw JS errors in the Classic Editor when the optimizer feature is turned on.

Credits

Props @dkotter, @turtlepod

Checklist: