<?php defined('ABSPATH') || exit;
$iv1wpt_has_pro = iv1wpt_has_pro();
?>
<h2><span class="dashicons dashicons-database"></span>&nbsp;<?php esc_html_e('Database Tables', 'iv1-wp-tools'); ?></h2>
<p class="description"><?php
    /* translators: %s: database table prefix, e.g. "wp_" */
    printf(esc_html__('Overview of all tables with prefix %s. Unassigned tables are considered orphaned.', 'iv1-wp-tools'), '<code>' . esc_html($GLOBALS['wpdb']->prefix) . '</code>');
?></p>
<div id="iv1wpt-tables-result" style="margin:15px 0;"></div>
<p>
	<button type="button" id="iv1wpt-tables-scan" class="button button-primary"><?php esc_html_e('Scan tables', 'iv1-wp-tools'); ?></button> 
	<?php if ($iv1wpt_has_pro) : ?>
    <button type="button" id="iv1wpt-tables-delete-selected" class="button" style="color:#b32d2e;"><?php esc_html_e('Delete selected', 'iv1-wp-tools'); ?></button>
	<?php else : ?>
    <button type="button" id="iv1wpt-tables-delete-selected" class="button" style="color:#b32d2e;" disabled> 🔒 <?php esc_html_e('Delete selected', 'iv1-wp-tools'); ?></button>
	<?php endif; ?>
</p>
<div id="iv1wpt-tables-list"><p class="description" style="font-style:italic;"><?php esc_html_e('Click "Scan tables" to start.', 'iv1-wp-tools'); ?></p></div>
<div style="margin-top:30px;padding-top:15px;border-top:1px solid #ddd;">
    <h3><?php esc_html_e('Table Whitelist', 'iv1-wp-tools'); ?></h3>
    <p class="description"><?php
        /* translators: %s: database table prefix, e.g. "wp_" */
        printf(esc_html__('Enter prefix (without %s), one per line.', 'iv1-wp-tools'), '<code>' . esc_html($GLOBALS['wpdb']->prefix) . '</code>');
    ?>
	</p>
	<form method="post" action="<?php echo esc_url(admin_url('admin.php?page=iv1-wp-tools&tab=tables')); ?>">
		<?php wp_nonce_field('iv1wpt_tables_whitelist_nonce'); ?>

		<textarea
			name="iv1wpt_tables_whitelist"
			rows="4"
			class="large-text code"
			style="max-width:400px;"
			<?php disabled(!$iv1wpt_has_pro); ?>
		><?php echo esc_textarea(get_option('iv1wpt_tables_whitelist','')); ?></textarea>

		<p class="submit" style="margin-top:8px;">
			<button
				type="<?php echo $iv1wpt_has_pro ? 'submit' : 'button'; ?>"
				name="iv1wpt_save_tables_whitelist"
				class="button button-primary"
				<?php disabled(!$iv1wpt_has_pro); ?>
			>
				<?php if (!$iv1wpt_has_pro) echo '🔒 '; ?>
				<?php esc_html_e('Save whitelist', 'iv1-wp-tools'); ?>
			</button>
		</p>
	</form>	
</div>