Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 4 years ago.
Improve this questioni have a deprecated function in my plugin code :
static function vksort(&$arr, $valuekey) {
$valuekey = sustr::preg_filter('A-Za-z0-9 ', $valuekey);
uasort($arr, create_function('$a,$b', 'return strcasecmp($a["'.$valuekey.'"], $b["'.$valuekey.'"]);'));
}
how i can change the create_function to function.
Closed. This question is off-topic. It is not currently accepting answers.Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 4 years ago.
Improve this questioni have a deprecated function in my plugin code :
static function vksort(&$arr, $valuekey) {
$valuekey = sustr::preg_filter('A-Za-z0-9 ', $valuekey);
uasort($arr, create_function('$a,$b', 'return strcasecmp($a["'.$valuekey.'"], $b["'.$valuekey.'"]);'));
}
how i can change the create_function to function.
Share Improve this question edited Feb 4, 2021 at 13:58 fuxia♦ 107k38 gold badges255 silver badges459 bronze badges asked Feb 4, 2021 at 13:08 Ziad El KhomssiZiad El Khomssi 11 silver badge2 bronze badges 1- 3rd party plugin dev support is off topic on this stack, you should ask the Ultimate SEO plugin support – Tom J Nowell ♦ Commented Feb 4, 2021 at 15:04
1 Answer
Reset to default 2Your server runs with a PHP version that doesn't support create_function.
From the PHP manual about create function
Warning This function has been DEPRECATED as of PHP 7.2.0, and REMOVED as of PHP 8.0.0. Relying on this function is highly discouraged.
If you are using PHP 5.3.0 or newer a native anonymous function should be used instead.
If the plugin is yours I would suggest just that, replace the create_function with anonymous function.
If the plugin is not yours and its a paid plugin, contact the plugin author and alert him of the error, ask him to give you the updated version.
If the plugin is free, you can update the code manually (If you know how), but that can be problematic. When the plugin will be updated your changes will be removed. If this is the only option, make sure to save the plugin with the changes somewhere safe so if the plugin will be updated you will have the previous plugin version with your fix for quick re-apply.
EDIT
Same code but with anonymous function
static function vksort(&$arr, $valuekey) {
$valuekey = sustr::preg_filter('A-Za-z0-9 ', $valuekey);
uasort($arr, function ($a, $b) use($valuekey) {
return strcasecmp($a[$valuekey], $b[$valuekey]);
});
}