Automattic / super-cool-ad-inserter-plugin

Insert ads, newsletter signup widgets, and calls to action in the middle of your posts!
https://wordpress.org/plugins/super-cool-ad-inserter/#description
32 stars 4 forks source link

fix: disable block if not using sidebars #99

Closed miguelpeixe closed 2 years ago

miguelpeixe commented 2 years ago

This PR disables the registration of the SCAIP block if the sidebars are disabled. SCAIP should assume that disabling sidebars means there is another method in place for handling how the ads are registered and rendered. There's no need for it to have its own block in such a case since it can duplicate and potentially conflict with the feature that has taken over.

To fix the integration with the block-based widget editor introduced by WordPress 5.8, this PR also removes the wp-editor dependency from the block editor JS. Declaring its dependency does not affect the block behavior.

How to test

Block-based widgets

  1. With a fresh installation running only this SCAIP branch, visit the widgets editor
  2. Confirm you are able to add a widget to the SCAIP sidebars and render it on the post

Disabled SCAIP block

  1. Running https://github.com/Automattic/newspack-plugin/pull/1550 with Newspack Ads and this branch of SCAIP, visit Newspack Ads -> Settings
  2. Confirm you have legacy mode for SCAIP turned on
  3. Create a new page and confirm the block works as expected
  4. Visit the Settings again and turn legacy mode off
  5. Confirm you are no longer able to add the block to a page
  6. Repeat the steps from "block-based widgets" and confirm it also works as expected

Note: If you are running an instance with Jetpack enabled and connected, you might still see the warning due to https://github.com/Automattic/jetpack/issues/20357

miguelpeixe commented 2 years ago

Thank you for catching that! I realize now that we should have a better strategy for disabling the use of the block instead of removing its registration entirely.

07a223ebe4c3fd7040d69ed32c561c5da6c0ac93 displays an error message on block edit and modifies the render callback.

image
matticbot commented 2 years ago

:tada: This PR is included in version 0.6.1-alpha.1 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

matticbot commented 2 years ago

:tada: This PR is included in version 0.6.1 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: