xtxpatch saves the email settings, still need to handle them

This commit is contained in:
asus
2024-03-31 19:25:39 +02:00
parent b4745ff672
commit 995e230e32
4 changed files with 40 additions and 9 deletions

View File

@@ -329,7 +329,6 @@ class Plgntls_xtx {
$function = $trace[1]['function'];
$file = $trace[0]['file'];
$line = $trace[0]['line'];
error_log("-debug: function '".$function."' (in ".$file.", line ".$line .')');
}
@@ -1086,7 +1085,6 @@ class Plgntls_xtx {
*
*/
$option_data = get_option($option_name);
error_log("get option safe: " . json_encode($option_data));
$false_serialized = serialize(false);
$option_unserialized = @unserialize($option_data);
if ($option_unserialized === false && $option_data != $false_serialized) {
@@ -1096,12 +1094,10 @@ error_log("get option safe: " . json_encode($option_data));
$ret_option = $option_unserialized;
}
error_log("get option safe: " . json_encode($ret_option));
return $ret_option;
}
public static function update_option_safe($option, $option_data) {
error_log("- inside update option safe");
/*
* first init option, in case it was not already
* it will returns the option name or false
@@ -1112,12 +1108,10 @@ error_log("- inside update option safe");
if (false === $option_name) {
return;
}
error_log("update option safe: " . json_encode($option_data));
if (!is_string($option_data)) {
$option_data = serialize($option_data);
}
error_log("update option safe: " . json_encode($option_data));
update_option($option_name, $option_data);
}

View File

@@ -18,6 +18,7 @@ if (!defined('ABSPATH')) {
class Xtxpatch {
const OPTION_REGISTER_EMAIL = [
'_name'=>'define_email_at_register_xtxpatch',
'_callback'=>__NAMESPACE__.'\define_register_email',
'_default'=>[
'email'=>
'Bonjour,

View File

@@ -46,6 +46,42 @@ function menu_content() {
function define_register_email($request, $option_name, $option_value, $option_default) {
/*
* email
*
*/
$email = '';
if (isset($request['email'])) {
$email = $request['email'];
}
/*
* is email ?
*
*/
$is_email_prof = false;
if (isset($request['is_email_prof']) && $request['is_email_prof'] === 'on') {
$is_email_prof = true;
}
$is_email_partner = false;
if (isset($request['is_email_partner']) && $request['is_email_partner'] === 'on') {
$is_email_partner = true;
}
/*
* update the option with new values
*
*/
$option_data = array(
'email' => $email,
'is_email_prof' => $is_email_prof,
'is_email_partner' => $is_email_partner,
);
\Plgntls_xtx::update_option_safe($option_name, $option_data);
}