wip menu can now receive form with rest api, but no nonce
This commit is contained in:
11
plugins/fbpatch/html/menu.html
Normal file
11
plugins/fbpatch/html/menu.html
Normal file
@@ -0,0 +1,11 @@
|
||||
<form action="<?php echo $fetch_url.'/'.$base_rest_route.'/choose'; ?>" method="POST">
|
||||
<div>
|
||||
<input type="checkbox" id="calculation_patch" name="calculation" checked />
|
||||
<label for="calculation_patch">calculation patch</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="checkbox" id="hide_show_elements" name="hide_show" />
|
||||
<label for="hide_show_elements">hide/show elements</label>
|
||||
</div>
|
||||
<input type="submit" value="send"/>
|
||||
</form>
|
||||
@@ -17,10 +17,33 @@ if (!defined('ABSPATH')) {
|
||||
*
|
||||
*/
|
||||
function plugin_content() {
|
||||
echo "<p>hello</p>";
|
||||
$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');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ class Fbpatch {
|
||||
|
||||
const SLUG_TOOGLE_ADMIN_MENU = ['_name'=>'toogle_admin_menu_url_fbpatch', 'toggle'=>'toggle', 'show'=>'show', 'hide'=>'hide'];
|
||||
const OPTION_TOGGLE_MENU = ['_name'=>'toggle_admin_menu_option_fbpatch', 'show'=>'show', 'hide'=>'hide'];
|
||||
const URL_BASE_REST_ROUTE = 'fbpatch_plugin/api/v1'; // for routes, in php/paypal/routes.php && php/admin_modif_prof.php
|
||||
|
||||
//private static $_is_
|
||||
|
||||
|
||||
Reference in New Issue
Block a user