move settings to template
This commit is contained in:
64
go-form-plugin/templates/settings-page.php
Normal file
64
go-form-plugin/templates/settings-page.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
if (!current_user_can('manage_options'))
|
||||
wp_die('No access.');
|
||||
|
||||
if (isset($_GET['deleted']))
|
||||
echo '<div class="notice notice-success"><p>Deleted!</p></div>';
|
||||
if (isset($_GET['created']))
|
||||
echo '<div class="notice notice-success"><p>Form created!</p></div>';
|
||||
?>
|
||||
|
||||
<div class="wrap">
|
||||
<h1>Go Form Settings</h1>
|
||||
|
||||
<h2>Create New Form</h2>
|
||||
<form method="post" action=" <?= admin_url('admin-post.php') ?> ">
|
||||
<?= wp_nonce_field('go_form_create_form_action', 'go_form_create_form_nonce', true, false) ?>
|
||||
<input type="hidden" name="action" value="go_form_create_form">
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<th>
|
||||
<label for="form_name">Form Name:</label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="text" name="form_name" id="form_name" required>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p class="submit"><input type="submit" class="button button-primary" value="Create Form"></p>
|
||||
</form>
|
||||
|
||||
<h2>Manage Forms & Entries</h2>
|
||||
|
||||
<?php
|
||||
|
||||
$selected_form_id = isset($_GET['form_id']) ? intval($_GET['form_id']) : 0;
|
||||
if ($selected_form_id) {
|
||||
|
||||
$form = go_form_get_form_by_id($selected_form_id);
|
||||
$form_name = $form ? $form->name : 'Unknown Form';
|
||||
echo "<h3> $form_name</h3>";
|
||||
echo '<div style="margin-bottom:15px">';
|
||||
|
||||
action_button('go_form_delete_form', 'Delete Form', 'Delete this form and ALL entries?', $selected_form_id);
|
||||
action_button('go_form_export', 'Export to CSV', 'Confrm Export', $selected_form_id);
|
||||
|
||||
echo '</div>';
|
||||
$entries = go_form_get_entries($selected_form_id);
|
||||
go_form_render_entries_table($entries, true);
|
||||
|
||||
} else {
|
||||
|
||||
$forms = go_form_get_forms();
|
||||
echo '<h3>Forms</h3><ul>';
|
||||
foreach ($forms as $f) {
|
||||
|
||||
$url = add_query_arg(array('page' => 'go-form-settings', 'form_id' => $f->id), admin_url('admin.php'));
|
||||
echo '<li><a href="' . esc_url($url) . '">' . esc_html($f->name) . '</a> <span style="color:#888">(ID: ' . esc_html($f->id) . ')</span> - <small>Shortcode: <code>[go_form id=' . esc_html($f->id) . ']</code></small></li>';
|
||||
}
|
||||
echo '</ul>';
|
||||
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
Reference in New Issue
Block a user