wip the nonce for the menu works

This commit is contained in:
asus
2024-03-23 22:14:16 +01:00
parent aae40be620
commit 46885fe10e
4 changed files with 64 additions and 37 deletions

View File

@@ -12,45 +12,12 @@ if (!defined('ABSPATH')) {
/*
* the construction of the admin menu page
* creates the plugin menu
*
*/
function plugin_content() {
$base_rest_route = Fbpatch::URL_BASE_REST_ROUTE;
$fetch_nonce = wp_create_nonce('wp_rest');
$fetch_url = get_site_url() . "/wp-json";
ob_start();
include(plugin_dir_path(__DIR__) . '/html/menu.html');
$html = ob_get_clean();
echo $html;
}
function choose_patches() {
error_log("---test---");
}
// handling routes and endpoints
// diff routes and endpoints : https://stackoverflow.com/q/56075017/9497573
function admin_menu_routes_endpoints() {
$base_rest_route = Fbpatch::URL_BASE_REST_ROUTE;
register_rest_route($base_rest_route, '/choose', array(
'methods' => 'POST',
'callback' => __NAMESPACE__.'\choose_patches',
));
};
add_action('rest_api_init', __NAMESPACE__.'\admin_menu_routes_endpoints');
/*
* menu plugin
*/
function plugin_menu() {
$menu_page_title = 'fbpatch';
$menu_title = 'fbpatch';