<?php
// Prevent direct access.
if (!defined('ABSPATH')) {
    exit;
}

/**
 * HTML template for å vise alle firewall regler som er automatisk lagt til.
 * 
 * Forventer å motta følgende variabler:
 * 
 * $msg = Eventuell success/error melding som skal settes inn på toppen av siden.
 * $htmlRuleList = HTML som settes inn i tabellen for å vise reglene.
 * 
 */
?>
<div class="wrap">
    <h1>Automatic Firewall Rules</h1>  
    
    <?php echo wp_kses_post($msg); ?>

    <p>
        Rules created automatically (for example, repeated failed logins).
    </p>

    <form id="auto-protect-form" method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>">
        <input type="hidden" name="action" value="wtb_firewall_bulk_auto_protect_rules" />
        <?php wp_nonce_field('wtb_firewall_bulk_auto_protect_rules', 'wtb_firewall_nonce'); ?>
        <div class="tablenav top">
            <div class="alignleft actions bulkactions">
                <label for="bulk-action-selector-top" class="screen-reader-text">Select bulk action</label>
                <select id="bulk-action-selector-top" name="bulk_action">
                    <option value="-1">Bulk actions</option>
                    <option value="bulk_delete">Delete</option>
                    <option value="bulk_make_permanent">Make permanent</option>
                </select>
                <button type="submit" class="button button-primary">Apply</button>
            </div>
        </div>
    </form>

    <br>

<table class="wp-list-table widefat fixed striped table-view-list">
    <thead>
        <tr>
            <th scope="col" class="manage-column column-cb check-column">
                <input type="checkbox" />
            </th>

            <th scope="col" class="manage-column column-primary column-ip">IP</th>
            <th scope="col" class="manage-column column-added">Added</th>
            <th scope="col" class="manage-column column-expires">Expires</th>
            <th scope="col" class="manage-column column-blocked">Blocked</th>
            <th scope="col" class="manage-column column-note">Note</th>
        </tr>
    </thead>

    <tbody id="the-list">
        <?php
            $allowed_html = wp_kses_allowed_html('post');

            $allowed_html['input'] = array(
                'form' => true,
                'type' => true,
                'name' => true,
                'value' => true,                                           
            );
            echo wp_kses($htmlRuleList, $allowed_html);
            ?>        
    </tbody>

    <tfoot>
        <tr>
            <th scope="col" class="manage-column column-cb check-column">
                <input type="checkbox" />
            </th>

            <th scope="col" class="manage-column column-primary column-ip">IP</th>
            <th scope="col" class="manage-column column-added">Added</th>
            <th scope="col" class="manage-column column-expires">Expires</th>
            <th scope="col" class="manage-column column-blocked">Blocked</th>
            <th scope="col" class="manage-column column-note">Note</th>
        </tr>
    </tfoot>
</table>

<br class="clear" />
</div>  
