Disclaimer: I have read and searched, quite a lot.
I am building my data to send via AJAX like this:
var plugin_data = [
plugin_action_button.attr('data-action-to-take'),
plugin_action_button.attr('data-plugin-slug')
];
requestPluginAction( JSON.stringify(plugin_data) );
If I am to console.log
, then it translates to:
["activate","handle"]
If I am to return what PHP is seeing, here's what it is:
[\"activate\",\"handle\"]
Now, running a simple json_decode
on that string:
check_ajax_referer( 'plugin_routines', 'security' );
$data = sanitize_text_field( $_POST['plugin_install_request_data'] );
wp_send_json( json_decode( $data ) );
Returns null.
I've tried a lot of things. json_decode
with true
set on, simply returning the unfiltered value I got from AJAX, etc.
But none works.
I'm ultimately looking to convert that JSON to a PHP array.