diff --git a/README.md b/README.md index 39b8a36..392f615 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,11 @@ - this project uses submodules recursively, so after cloning you need to do : `git submodule update --init --recursive` -- `wp_add_inline_script` +### todo : +- [read this guide to plugins development](https://developer.wordpress.org/plugins/) +- [learning about the rest api](https://developer.wordpress.org/plugins/settings/options-api/) +- ajax : + - [using fetch ajax](https://ricard.dev/how-to-use-wordpress-admin-ajax-with-fetch-api/) + - [wp ajax course](https://developer.wordpress.org/plugins/javascript/ajax/) + - [examples from stackoverflow](https://stackoverflow.com/questions/43557755/how-to-call-ajax-in-wordpress) + - using `admin_url('admin-ajax.php')` or `wp-utils` diff --git a/plugins/wp_model_plugin/php/menu/menu.php b/plugins/wp_model_plugin/php/menu/menu.php new file mode 100644 index 0000000..c28aab3 --- /dev/null +++ b/plugins/wp_model_plugin/php/menu/menu.php @@ -0,0 +1,27 @@ + + + + + "; +} + +?> diff --git a/plugins/wp_model_plugin/plugin_hooks.php b/plugins/wp_model_plugin/plugin_hooks.php index 01ac1e2..a0de4ad 100644 --- a/plugins/wp_model_plugin/plugin_hooks.php +++ b/plugins/wp_model_plugin/plugin_hooks.php @@ -93,4 +93,11 @@ function plugin_menu() { } add_action('admin_menu', 'plugin_menu'); +add_action( 'wp_ajax_nopriv_get_data', 'my_ajax_handler' ); +add_action( 'wp_ajax_get_data', 'my_ajax_handler' ); + +function my_ajax_handler() { + wp_send_json_success( 'It works' ); +} + ?>