This module allows you to add event handlers to blocks to execute custom JavaScript snippets.
Currently only the button block can add event handler.
You can enable this module via “WordPress Dashboard -> Plover Kit -> Modules -> Block Event Handler“
Module Settings
You can visit the module settings via “WordPress Dashboard -> Plover Kit -> Modules -> Block Event Handler -> Settings“
Allowed Roles
If your site allows guest posts, it is risky to allow authors and contributors to add JavaScript to the page, which they might use to inject harmful code.
In special cases, you may want to allow only administrators to add JavaScript, you can configure it here.
Allowed Events
Three standard mouse events are currently supported. For security reasons, you can remove unused events here. Removed event types will not take effect in the editor and frontend.
Here are the currently supported events.
Block Settings
You can find the JavaScript Event Handler group in the Advanced panel of the button block settings.
By clicking the three dots after the tab, you can select other available events.
Edit Event Handler
Let’s take the click event as an example. Click the Edit on click event button.
A code editor modal will then pop up, your can enter your own JavaScript logic. The following example will pop up a dialog with “Hello World!!” when the button is clicked.
Don’t forget to save your post after you’ve finished editing it to take effect!
Here’s the effect on the frontend.
Leave a Reply