Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Relevant part of callback for add_suubmenu_page()
- <form method="POST" action="<?php echo admin_url('admin-post.php?action=dc_convert'); ?>" novalidate="novalidate">
- <input type="hidden" id="_wpnonce" name="_wpnonce" value="<?php echo wp_create_nonce('dc_convert'); ?>" />
- The rest of input fields go here
- </form>
- <?php
- // Form submit handler
- add_action('admin_post_dc_convert', 'dc_do_conversion');
- function dc_do_conversion() {
- ?>
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
- <head>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>Conversion Result</title>
- </head>
- <body>
- <h1>Conversion Results</h1>
- <?php
- if ( ! check_admin_referer('dc_convert')) wp_die('Invalid form data');
- if ( ! current_user_can('manage_options')) wp_die('You do not have proper user capability to do this.');
- if ( ! empty( $_POST )) {
- $source = stripslashes( $_POST['dc-source']);
- if (''== $source) {
- echo 'Content is empty!';
- } else {
- // do a bunch of processing
- echo <<<EOT
- $content
- EOT;
- // EOT; must be at col 0!
- } // if empty data
- } // if 'POST'
- ?>
- </body>
- </html>
- <?php
- exit;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement