# double-opt-in/2.11/ui/UISettings.class.php

Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification, version 2.11. 166 lines.

- Page: https://pluginprobe.com/plugins/double-opt-in/2.11/code/ui/UISettings.class.php
- Raw: https://pluginprobe.com/plugins/double-opt-in/2.11/raw/ui/UISettings.class.php
- Modified: 2022-12-16T11:04:54+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/double-opt-in/2.11/code/ui/UISettings.class.php#L10-L20`.

```php
<?php

namespace forge12\contactform7\CF7DoubleOptIn {
    if (!defined('ABSPATH')) {
        exit;
    }

    /**
     * Class UIDashboard
     *
     * @package forge12\contactform7\CF7DoubleOptIn
     */
    class UISettings extends UIPageForm
    {
        public function __construct($domain)
        {
            parent::__construct($domain, 'settings', 'Settings');
        }

        /**
         * Render the license subpage content
         */
        protected function theContent($slug, $page, $settings)
        {
            $deleteOptionItems = array(
                0 => 'never',
            );

            for($i = 1; $i < 31; $i++){
                $deleteOptionItems[$i] = $i;
            }

            $deleteOptionPeriod = array(
                'months' => 'months',
                'days' => 'days',
                'years' => 'years'
            )

            ?>
            <h2>
                <?php _e('Settings', 'double-opt-in'); ?>
            </h2>

            <div class="option">
                <div class="label">
                    <label for="delete"><?php _e('Delete Opt-Ins', 'double-opt-in'); ?></label>
                </div>
                <div class="input">
                    <select id="delete" name="delete">
                        <?php
                        foreach ($deleteOptionItems as $month => $label):
                            ?>
                            <option value="<?php esc_attr_e($month); ?>" <?php echo $month == $settings['delete'] ? ' selected="selected" ' : ''; ?> >
                                <?php _e($label, 'double-opt-in'); ?>
                            </option>
                        <?php endforeach; ?>
                    </select>

                    <select id="delete_period" name="delete_period">
                        <?php
                        foreach ($deleteOptionPeriod as $key => $value):
                            ?>
                            <option value="<?php esc_attr_e($key); ?>" <?php echo $key == $settings['delete_period'] ? ' selected="selected" ' : ''; ?> >
                                <?php _e($value, 'double-opt-in'); ?>
                            </option>
                        <?php endforeach; ?>
                    </select>

                    <p>
                        <?php _e('Select the period of time after which all data will be deleted automatically. As for the european GDPR it is recommend to use the smallest period of time as possible.', 'double-opt-in'); ?>
                    </p>
                </div>
            </div>

            <div class="option">
                <div class="label">
                    <label for="delete_unconfirmed"><?php _e('Delete unconfirmed Opt-Ins', 'double-opt-in'); ?></label>
                </div>
                <div class="input">
                    <select id="delete_unconfirmed" name="delete_unconfirmed">
                        <?php
                        foreach ($deleteOptionItems as $month => $label):
                            ?>
                            <option value="<?php esc_attr_e($month); ?>" <?php echo $month == $settings['delete_unconfirmed'] ? ' selected="selected" ' : ''; ?> >
                                <?php _e($label, 'double-opt-in'); ?>
                            </option>
                        <?php endforeach; ?>
                    </select>

                    <select id="delete_unconfirmed_period" name="delete_unconfirmed_period">
                        <?php
                        foreach ($deleteOptionPeriod as $key => $value):
                            ?>
                            <option value="<?php esc_attr_e($key); ?>" <?php echo $key == $settings['delete_unconfirmed_period'] ? ' selected="selected" ' : ''; ?> >
                                <?php _e($value, 'double-opt-in'); ?>
                            </option>
                        <?php endforeach; ?>
                    </select>
                    <p>
                        <?php _e('Select the period of time after which all unconfirmed data will be deleted automatically. As for the european GDPR it is recommend to use the smallest period of time as possible.', 'double-opt-in'); ?>
                    </p>
                </div>
            </div>

            <div class="option">
                <div class="label">
                    <label for="support"><?php _e('Support Forge12 Double Opt-in: ', 'double-opt-in'); ?></label>
                </div>
                <div class="input">
                    <input type="hidden" class="toggle" name="support"
                           value="<?php esc_attr_e($settings['support']); ?>"
                           data-before="<?php _e('On', 'double-opt-in'); ?>"
                           data-after="<?php _e('Off', 'double-opt-in'); ?>"/>

                    <p>
                        <?php _e('The Footer will contain a noscript referral to support Forge12 Double Opt-in.', 'double-opt-in'); ?>
                    </p>
                </div>
            </div>

            <?php
        }

        protected function theSidebar($slug, $page)
        {
            if ($page != 'settings') {
                return;
            }
            ?>
            <div class="box">
                <h2>
                    <?php _e('Hint:', 'double-opt-in'); ?>
                </h2>
                <p>
                    <?php _e("In the table on the left side, you'll find an list global settings. They will affect all forms using the double opt-in.", 'double-opt-in'); ?>
                </p>
            </div>
            <?php
        }

        public function getSettings($settings)
        {
            $settings = array_merge($settings, array(
                    'support' => 1,
                    'delete' => 0,
                    'delete_unconfirmed' => 7,
                    'delete_period' => 'months',
                    'delete_unconfirmed_period' => 'months'
                )
            );

            return $settings;
        }

        protected function onSave($settings)
        {
            $settings['delete'] = (int)$_POST['delete'];
            $settings['delete_unconfirmed'] = (int)$_POST['delete_unconfirmed'];
            $settings['support'] = (int)$_POST['support'];
            $settings['delete_period'] = sanitize_text_field($_POST['delete_period']);
            $settings['delete_unconfirmed_period'] = sanitize_text_field($_POST['delete_unconfirmed_period']);

            return $settings;
        }
    }
}
```
