fixed error with option update
This commit is contained in:
@@ -1086,19 +1086,22 @@ class Plgntls_xtx {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
$option_data = get_option($option_name);
|
$option_data = get_option($option_name);
|
||||||
|
error_log("get option safe: " . json_encode($option_data));
|
||||||
$false_serialized = serialize(false);
|
$false_serialized = serialize(false);
|
||||||
$option_unserialized = @unserialize($option_data);
|
$option_unserialized = @unserialize($option_data);
|
||||||
if ($option_unserialized === false && $option_data != $false_serialized) {
|
if ($option_unserialized === false && $option_data != $false_serialized) {
|
||||||
$ret_option = $option_data;
|
$ret_option = $option_data;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$ret_option = $options_unserialized;
|
$ret_option = $option_unserialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error_log("get option safe: " . json_encode($ret_option));
|
||||||
return $ret_option;
|
return $ret_option;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function update_option_safe($option, $option_data) {
|
public static function update_option_safe($option, $option_data) {
|
||||||
|
error_log("- inside update option safe");
|
||||||
/*
|
/*
|
||||||
* first init option, in case it was not already
|
* first init option, in case it was not already
|
||||||
* it will returns the option name or false
|
* it will returns the option name or false
|
||||||
@@ -1109,10 +1112,12 @@ class Plgntls_xtx {
|
|||||||
if (false === $option_name) {
|
if (false === $option_name) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
error_log("update option safe: " . json_encode($option_data));
|
||||||
|
|
||||||
if (!is_string($option_data)) {
|
if (!is_string($option_data)) {
|
||||||
$option_data = serialize($option_data);
|
$option_data = serialize($option_data);
|
||||||
}
|
}
|
||||||
|
error_log("update option safe: " . json_encode($option_data));
|
||||||
update_option($option_name, $option_data);
|
update_option($option_name, $option_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1291,15 +1296,17 @@ class Plgntls_xtx {
|
|||||||
* if nonce passed, call the callback
|
* if nonce passed, call the callback
|
||||||
* - with the remaining of the request
|
* - with the remaining of the request
|
||||||
* - the option name
|
* - the option name
|
||||||
* - and the option value
|
* - the option default value
|
||||||
|
* - and the option default data to have the fields
|
||||||
*
|
*
|
||||||
|
$nonce_callback($request, $option_name, $option_data['_default']);
|
||||||
*/
|
*/
|
||||||
$option_value = self::get_option_safe($option_name);
|
$option_value = self::get_option_safe($option_name);
|
||||||
if (false === $option_value) {
|
if (false === $option_value) {
|
||||||
self::redirect_menu_referer();
|
self::redirect_menu_referer();
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$nonce_callback($request, $option_name, $option_value);
|
$nonce_callback($request, $option_name, $option_value, $option_data['_default']);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* then redirects
|
* then redirects
|
||||||
@@ -1309,7 +1316,7 @@ class Plgntls_xtx {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function default_handle_admin_post_option($request, $option_name, $option_data) {
|
public static function default_handle_admin_post_option($request, $option_name, $option_data, $option_default) {
|
||||||
/*
|
/*
|
||||||
* in case the option only contains one value, just update it
|
* in case the option only contains one value, just update it
|
||||||
*
|
*
|
||||||
@@ -1324,7 +1331,7 @@ class Plgntls_xtx {
|
|||||||
* update each values
|
* update each values
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
foreach ($option_data as $key) {
|
foreach ($option_default as $key => $value) {
|
||||||
if (isset($request[$key])) {
|
if (isset($request[$key])) {
|
||||||
$option_data[$key] = $request[$key];
|
$option_data[$key] = $request[$key];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user