I'm developing a wordpress plugin and looking to save data entered in a block to a mySQL table. That's it. But how can data be sent from the block editor to the server side? I've spent two weeks looking for the appropriate technique and no joy.
The scenario is simple:
registerBlockType("bla/quote-block", { //...
attributes: { quoteAtt: { type: 'string' } },
edit: function(props) {
props.setAttributes( { quoteAtt: getQuote() } );
// ?? Send props.quoteAtt to the server ??
}
I've found how to use AJAX + jQuery + wp_localize_script
but that method apparently is only suitable for sending data from the front end (eg form data). The REST API is horrendously complex and all the documentation is about reading post [meta] data, not about saving data into a table.
Thank you!
wp-json/...
urldbDelta
and ways to make raw queries likewpdb
, WP provides nothing for custom tables, no endpoints, no UI, etc, by choosing a custom table instead of a CPT you've chosen to do everythng from scratch