WordPress phpのバージョンを5.6から7.3に上げた時にLION BLOGでエラーが発生

WordPress phpのバージョンを5.6から7.3に上げた時にLION BLOGでエラーが発生

WordPressで利用しているphpのバージョンを5.6から7.3に上げた時にテーマLION BLOGでエラー「Deprecated: Function create_function() is deprecated in /home/users/xxx/wp-content/themes/lionblog/functions.php on line 4514」が発生した際の対処法を記述してます。

環境

  • WordPress 5.5.1
  • LION BLOG 2.0.0

エラー全文

以下のエラーが発生しました。

Deprecated: Function create_function() is deprecated in /home/users/xxx/wp-content/themes/lionblog/functions.php on line 4514

Deprecated: Function create_function() is deprecated in /home/users/xxx/wp-content/themes/lionblog/functions.php on line 4613

Warning: Cannot modify header information - headers already sent by (output started at /home/users/xxx/wp-content/themes/lionblog/functions.php:4514) in /home/users/xxx/wp-includes/functions.php on line 6270

Warning: Cannot modify header information - headers already sent by (output started at /home/users/xxx/wp-content/themes/lionblog/functions.php:4514) in /home/users/xxx/wp-admin/includes/misc.php on line 1310

Warning: Cannot modify header information - headers already sent by (output started at /home/users/xxx/wp-content/themes/lionblog/functions.php:4514) in /home/users/xxx/wp-admin/admin-header.php on line 9

原因

create_functionは、php7.2から非推奨になっているため

対処法

「/mebee/wp-content/themes/lionblog/functions.php」の以下の2箇所をコメントアウトして、create_functionを使用しないように変更します。

//add_action( 'widgets_init', create_function( '', 'return register_widget( "AdWidgetItemClass" );' ) );

add_action( 'widgets_init', function(){
	register_widget( 'AdWidgetItemClass' );
});
//add_action( 'widgets_init', create_function( '', 'return register_widget( "Popular_Posts" );' ) );
add_action( 'widgets_init', function(){
	register_widget( 'Popular_Posts' );
});