希望代码是不言自明的
// Add a new submenu page and also add a load handler for it to process POSTs
($hook_name = add_submenu_page(
\'plugins.php\', // Under plugins menu
\'Title\',
\'Menu\',
\'activate_plugins\', // Administrators
\'slug\',
function(){ // Visual is here ?>
<div class="wrap">
<h2>Sub-Page Title</h2>
<!-- Subpage visual output comes here -->
</div>
<?php })) and (add_action("load-{$hook_name}", function(){ // Hook the load here
if(!strcasecmp($_SERVER[\'REQUEST_METHOD\'], \'POST\')){
$_POST = stripslashes_deep($_POST); // Fix this WP BS security joke
// Handle a POST request
// ... Do stuff with $_POST
}elseif(!strcasecmp($_SERVER[\'REQUEST_METHOD\'], \'GET\')){
// Handle a GET (normal) request
// ... Usually not needed
}
}));
Have fun!