<?php if (!defined('TWEAKR_INIT')) die('DIRECT ACCESS PROHIBITED'); ?>

    <!-- E-Mail -->
    <div class="postbox tweakr-postbox">
    <h3 class="hndle"><span><?php _e('E-Mail', 'tweakr'); ?></span></h3>
    <div class="inside tweakr-setting-section">

        <?php 
            // Control User E-Mail Notification
            $this->_settingsUtility->displaySelect(__('New User Notification', 'tweakr'), 'user-registration-email-notification', array(
                'default' => 'Default behaviour',
                'both' => 'Notify Admin + User',
                'admin' => 'Notify Admin only',
                'user' => 'Notify User only',
                'none' => 'Disable Notifications'
            ), array(
                'label' => 'Should an E-Mail send to the new User and/or the site admin?',
                'description' => 'On each new User Registration WordPress will send a notifcation to the Site Admin (New User has been registered) as well as the Login Credentials to the new User. Sometimes it is required to suppress those E-Mails.'
            ));

        ?>

        <h4>Mail Settings</h4>

        <?php

            // SMTP Transport
            $this->_settingsUtility->displayCheckbox(__('SMTP', 'tweakr'), 'email-smtp-enabled', array(
                'label' => 'Use external SMTP Server to send mails.',
                'description' => 'The PHPMailer system used by WordPress provides the ability to send E-Mails via an external SMTP Server.',
                'readmore'=> 'https://github.com/PHPMailer/PHPMailer/blob/master/examples/smtp.phps'
            ));

            // Mail From
            $this->_settingsUtility->displayCheckbox(__('Fix Mail-From', 'tweakr'), 'email-from-auto', array(
                'label' => 'Enable',
                'description' => 'Sets the Mail-From parameter to BLOGNAME<wordpress@yourdomain.tld>. This fix will solve problems with phpmailerExceptions which are caused by a malformed/invalid email-from-address.'
            ));

        ?>

        <div class="tweakr-selective-section" data-trigger="#tweakr-email-from-auto" data-condition="!checked">

        <?php

            $this->_settingsUtility->displayInput(__('From Name', 'tweakr'), 'email-from-name', array(
                'placeholder' => 'auto',
                'label' => 'Sender Name',
                'cssClass' => 'input-large',
                'description' => 'Leave blank to use default value.'
            ));

            $this->_settingsUtility->displayInput(__('From Address', 'tweakr'), 'email-from-address', array(
                'placeholder' => 'auto',
                'label' => 'Sender Address',
                'cssClass' => 'input-large',
                'description' => 'Leave blank to use default value.'
            ));
        ?>

        </div>

        <div class="tweakr-selective-section" data-trigger="#tweakr-email-smtp-enabled" data-condition="checked">

            <h4>SMTP Settings</h4>

            <?php
            // Hostname
            $this->_settingsUtility->displayInput(__('Hostname', 'tweakr'), 'email-smtp-host', array(
                'placeholder' => 'smtp.example.org',
                'label' => 'Mailserver Hostname',
                'cssClass' => 'input-large',
                'description' => 'You will receive these settings from your webhosting provider.'
            ));

            // Port
            $this->_settingsUtility->displayInput(__('Port', 'tweakr'), 'email-smtp-port', array(
                'placeholder' => '587',
                'label' => 'The Port of your Mailserver',
                'description' => 'Typically 25 for unsecure connections or 465/587 for secure TLS connections.'
            ));

            // SSL/TLS
            $this->_settingsUtility->displaySelect(__('Secure Connection', 'tweakr'), 'email-smtp-ssltls', array(
                'none' => 'No Encryption',
                'tls' => 'TLS Encryption (recommended)',
                'ssl' => 'SSL Encryption (deprecated)'
            ), array(
                'label' => 'Enable secure connection via SSL/TLS',
                'description' => 'The Port should be set to 587 for TLS or 465 for SSL (deprecated) but may differ depending on your hosting provider.',
                'cssClass' => 'input-large'
            ));

            // Username
            $this->_settingsUtility->displayInput(__('Username', 'tweakr'), 'email-smtp-username', array(
                'placeholder' => 'sendmail@example.org',
                'label' => 'SMTP Username (Username of the Mailbox)',
                'cssClass' => 'input-large',
            ));

            // Password
            $this->_settingsUtility->displayInput(__('Password', 'tweakr'), 'email-smtp-password', array(
                'label' => 'SMTP Password',
                'cssClass' => 'input-large',
            ));

            ?>

        </div>

    <!-- // E-Mail -->
    </div></div>

    <!-- Automatic Updates -->
    <div class="postbox tweakr-postbox">
    <h3 class="hndle"><span><?php _e('Automatic Updates (WordPress Installation)', 'tweakr'); ?></span></h3>
    <div class="inside tweakr-setting-section">

        <p>As a security feature, WordPress provides an automatic-update mechanism to keep your installation up-to-date. In some special cases you may want to change the update policy or enable automatic updates for plugins and themes.</p>

        <?php
            // Global
            $this->_settingsUtility->displayCheckbox(__('Disable Automatic Updates', 'tweakr'), 'autoupdate-disable', array(
                'label' => 'Disable All',
                'description' => 'In some special cases it might be required (but not recommended!) to disable all types of automatic updates.',
                'readmore' => 'https://codex.wordpress.org/Configuring_Automatic_Background_Updates'
            ));
            
            // Notifications
            $this->_settingsUtility->displayCheckbox(__('E-Mail Notifications', 'tweakr'), 'autoupdate-notifications', array(
                'label' => 'Enable',
                'description' => 'An automatic E-Mail notification is send to the default address in case an automatic update happened or failed.',
                'readmore' => 'https://codex.wordpress.org/Configuring_Automatic_Background_Updates'
            ));
        ?>

        <h4><?php _e('Component Update Policy', 'tweakr'); ?></h4>

        <?php
            
            // core
            $this->_settingsUtility->displaySelect(__('Core Updates', 'tweakr'), 'autoupdate-core', array(
                'default' => 'Default behaviour (enabled)',
                'enabled' => 'Enable Core Updates (enforced)',
                'disabled' => 'Disable Core Updates (enforced)',
            ), array(
                'label' => 'Core Policy',
                'description' => 'By default, the Core (WordPress Installation) is automatically updated by WordPress.',
                'readmore' => 'https://codex.wordpress.org/Configuring_Automatic_Background_Updates'
            ));

            // plugins
            $this->_settingsUtility->displaySelect(__('Plugin Updates', 'tweakr'), 'autoupdate-plugins', array(
                'default' => 'Default behaviour (disabled)',
                'enabled' => 'Enable Plugin Updates (enforced)',
                'disabled' => 'Disable Plugin Updates (enforced)',
            ), array(
                'label' => 'Plugin Policy',
                'description' => 'By default, plugins are not automatically updated by WordPress.',
                'readmore' => 'https://codex.wordpress.org/Configuring_Automatic_Background_Updates'
            ));

            // themes
            $this->_settingsUtility->displaySelect(__('Theme Updates', 'tweakr'), 'autoupdate-themes', array(
                'default' => 'Default behaviour (disabled)',
                'enabled' => 'Enable Theme Updates (enforced)',
                'disabled' => 'Disable Theme Updates (enforced)',
            ), array(
                'label' => 'Theme Policy',
                'description' => 'By default, themes are not automatically updated by WordPress.',
                'readmore' => 'https://codex.wordpress.org/Configuring_Automatic_Background_Updates'
            ));

            // translations
            $this->_settingsUtility->displaySelect(__('Translation Updates', 'tweakr'), 'autoupdate-translations', array(
                'default' => 'Default behaviour (enabled)',
                'enabled' => 'Enable Translation Updates (enforced)',
                'disabled' => 'Disable Translation Updates (enforced)',
            ), array(
                'label' => 'Translation Policy',
                'description' => 'By default, translations are automatically updated by WordPress.',
                'readmore' => 'https://codex.wordpress.org/Configuring_Automatic_Background_Updates'
            ));

        ?>

    <!-- // Automatic Updates -->
    </div></div>
