Skip to content

Instantly share code, notes, and snippets.

@iankuan
Last active February 21, 2022 13:32
Show Gist options
  • Select an option

  • Save iankuan/837ef42d3ecc54ce8f7799cfcb3e37ad to your computer and use it in GitHub Desktop.

Select an option

Save iankuan/837ef42d3ecc54ce8f7799cfcb3e37ad to your computer and use it in GitHub Desktop.
Please fill missing code. This is an excel exporter program.
<?php
class Plugin {
function __construct()
{
add_action('admin_menu', array($this, 'adminPage'));
add_action('admin_init', array($this, 'settings'));
}
function settings(){
add_settings_section('first_section', NULL, NULL, 'sub-excel-export');
add_settings_field( 'exportFormId', 'Choose the form: ',
array($this, 'locationHTML'), 'sub-excel-export', 'first_section');
register_setting('cam', 'exportFormId',
array('export_callback' => 'exportFormId', 'default' => '0'));
}
function locationHTML () { ?>
<select name="exportFormId">
<option value="1" <?php selected(get_option('exportFormId'), '1') ?>>Form 1</option>
</select>
<?php }
function adminPage()
{
add_menu_page(
'Exporter', // page title
'Submission Excel Exporter', // menu title
'manage_options', // capability
'sub-excel-export', // menu slug
array($this, 'ourHTML') // callback function
);
}
// function handleForm() {
// //TODO
// exportExcel($input);
// }
function ourHTML() { ?>
<div class="wrap">
<h1> Submission Excel Exporter </h1>
<!-- TODO: Pass value to handleForm()
or in any way, but remember to trigger exportExcel($id) -->
</div>
<?php }
}
$plugin = new Plugin();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment