Where do I hook to have the server do something in PHP on block attribute change?


I’m creating a new block plugin, and I’d like the server to do some stuff when certain attributes change. I’m thinking I’m looking for something like

function my_attribute_changed ( $block_ID, $attribute, $value ) {
        // do some stuff
add_action('gutenberg-attribute-change', 'my_attribute_changed', 10, 3);

but I’m not seeing any such thing in the docs, and am thinking maybe I’m barking up the wrong tree, so to speak.

I imagine there are lots of reasons one may want to do such a thing, but in this particular instance, the block’s edit function has an attribute that is a URL that points to a 3rd party API. My plan is set a wp_cron to grab the data at regular intervals, and store it in transient. Then the block’s save function will grab that transient data via AJAX.

philolegein 4 months 0 Answers 7 views 0

Leave an answer