Plugin Directory

Changeset 3431943


Ignore:
Timestamp:
01/04/2026 04:50:34 AM (2 weeks ago)
Author:
realpinny
Message:

small update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pinnys-simple-smtp/trunk/pinnys-simple-smtp.php

    r3430827 r3431943  
    6363        add_action('admin_init', [$this, 'handle_test_email']);
    6464        add_action('phpmailer_init', [$this, 'configure_smtp']);
     65        add_filter('pre_update_option_pinnys_smtp_password', [$this, 'pre_update_password'], 10, 2);
    6566    }
    6667   
     
    8485        register_setting(PINNYS_SMTP_GROUP, 'pinnys_smtp_from_email', 'sanitize_email');
    8586        register_setting(PINNYS_SMTP_GROUP, 'pinnys_smtp_from_name', 'sanitize_text_field');
    86 
    87         register_setting(PINNYS_SMTP_GROUP, 'pinnys_smtp_password', [
    88             'sanitize_callback' => [$this, 'process_password_save']
    89         ]);
    90     }
    91 
    92     public function process_password_save($input) {
    93         if (empty($input)) {
    94             return get_option('pinnys_smtp_password');
    95         }
    96         return pinnys_smtp_encrypt($input);
     87        register_setting(PINNYS_SMTP_GROUP, 'pinnys_smtp_password');
     88    }
     89   
     90    public function pre_update_password($new_value, $old_value) {
     91        $new = trim((string) $new_value);
     92       
     93        if ($new === '') {
     94            return $old_value;
     95        }
     96       
     97        $encrypted = pinnys_smtp_encrypt($new);
     98        return ($encrypted !== false && $encrypted !== '') ? $encrypted : $old_value;
    9799    }
    98100
    99101    public function handle_test_email() {
    100         // Strict Page Check
    101102        if (!isset($_GET['page']) || $_GET['page'] !== PINNYS_SMTP_SLUG) {
    102103            return;
Note: See TracChangeset for help on using the changeset viewer.