wip adding attributes, works with filter wp-script-attributes

This commit is contained in:
asus
2024-02-27 11:51:46 +01:00
parent 81f3f8a7e7
commit 7a8c0750c5
4 changed files with 87 additions and 47 deletions

View File

@@ -353,34 +353,4 @@ add_action('admin_menu', 'fipfcard_plugin_menu');
/*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
ajax
- https://stackoverflow.com/questions/43557755/how-to-call-ajax-in-wordpress
- in `add_action( 'wp_ajax_get_data', 'my_ajax_handler' );`
the 'wp_ajax_get_data' is a hooks formated as 'wp_ajax_{$action}'
the `$action` param is passed in the data object of the ajax call
- to access the content of the data object properties of the ajax call :
use $_POST['property_name']
*/
function fipfcard_ajax_handler()
{
wp_send_json_success( array
(
'It works',
"data_received" => $_POST,
),
200
);
}
function fipfcard_menu_endpoint()
{
register_rest_route('', '/get_data', array(
'methods' => 'POST',
'callback' => 'fipfcard_ajax_handler',
));
};
add_action('rest_api_init', 'fipfcard_menu_endpoint');
?>