fixed error with automatically adding _name to option
This commit is contained in:
@@ -35,9 +35,10 @@ function add_plugin_content_CIPF() {
|
||||
* options
|
||||
*
|
||||
*/
|
||||
$option_paypal = Plgntls::get_option_safe($option_paypal_object);
|
||||
$option_payment = Plgntls::get_option_safe($option_payment_object);
|
||||
$option_emails = Plgntls::get_option_safe($option_emails_object);
|
||||
$option_paypal = Plgntls::get_option_safe($option_paypal_object, true);
|
||||
$option_payment = Plgntls::get_option_safe($option_payment_object, true);
|
||||
//delete_option($option_emails_object['_name']);
|
||||
$option_emails = Plgntls::get_option_safe($option_emails_object, true);
|
||||
|
||||
ob_start();
|
||||
include(Plgntls::root_path() . '/html/menu/cipf_menu.html');
|
||||
@@ -171,13 +172,15 @@ function update_emails_settings_option_CIPF($request, $option_name, $option_data
|
||||
//error_log("option_data bedore: " . json_encode($option_data));
|
||||
foreach ($option_data as $email_type => $email_options) {
|
||||
//error_log("email_type: " . $email_type);
|
||||
if ($email_type === '_name') {
|
||||
continue;
|
||||
}
|
||||
$ret_email = update_email_by_type_CIPF($email_type, $email_options, $request);
|
||||
if ($ret_email !== false) {
|
||||
$option_data[$email_type] = $ret_email;
|
||||
}
|
||||
// if ($email_type === '_name') {
|
||||
// continue;
|
||||
// }
|
||||
// $ret_email = update_email_by_type_CIPF($email_type, $email_options, $request);
|
||||
// if ($ret_email !== false) {
|
||||
// $option_data[$email_type] = $ret_email;
|
||||
// }
|
||||
|
||||
$option_data[$email_type] = update_email_by_type_CIPF($email_type, $email_options, $request);
|
||||
}
|
||||
//error_log("option_data after : " . json_encode($option_data));
|
||||
|
||||
@@ -193,9 +196,9 @@ function update_emails_settings_option_CIPF($request, $option_name, $option_data
|
||||
function update_email_by_type_CIPF($email_type, $email_options, $request) {
|
||||
Plgntls::debug_infos();
|
||||
//error_log("email type: " . $email_type);
|
||||
if ($email_type === '_name') {
|
||||
return false;
|
||||
}
|
||||
//if ($email_type === '_name') {
|
||||
// return false;
|
||||
//}
|
||||
|
||||
/*
|
||||
* set notification/confirmation_send to false by default,
|
||||
|
||||
@@ -1066,7 +1066,7 @@ class Plgntls {
|
||||
|
||||
|
||||
|
||||
public static function get_option_safe($option) {
|
||||
public static function get_option_safe($option, $name = false) {
|
||||
/*
|
||||
* first init option, in case it was not already
|
||||
* it will returns the option name or false
|
||||
@@ -1098,11 +1098,20 @@ class Plgntls {
|
||||
}
|
||||
|
||||
/*
|
||||
* if option is an array and _name is not define,
|
||||
* add the _name entry to the output, to facilitate the access to the name
|
||||
* $name is true,
|
||||
* add the _name entry to the output,
|
||||
* it will overwrite any existing _name key
|
||||
* if option is not an array,
|
||||
* make it array and put the value into a '_value' key
|
||||
*
|
||||
*
|
||||
*/
|
||||
if (is_array($ret_option) && !isset($ret_option['_name'])) {
|
||||
if ($name === true) {
|
||||
if (!is_array($ret_option)) {
|
||||
$value = $ret_option;
|
||||
$ret_option = array();
|
||||
$ret_option['_value'] = $value;
|
||||
}
|
||||
$ret_option['_name'] = $option_name;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user