Option 1
您是否尝试过更改函数名?类似的东西
function getClientFn($function){}? 你可以保留你想要的任何名字。
function getClientFn($function){
return \'\\DisplaceTech\\Companies\\\\\' . $function;
}
function add_clients_metabox(){
$screens = [\'page\'];
foreach ($screens as $screen) {
add_meta_box(
\'clients\', // Unique ID
__(\'Clients\'), // Box title
getClientFn(\'clients_box_html\'), // Content callback, must be of type callable
$screen, // Post type
\'advanced\', // Context
\'high\' // Priority
);
}
}
add_action(\'add_meta_boxes\', \'add_clients_metabox\');
Option 2: 如果您真的需要保留“fn”方法,请尝试使用在php 7.4中工作的以下脚本。
$myfunction = fn($function) => \'\\DisplaceTech\\Companies\\\\\' . $function;
function add_clients_metabox(){
$screens = [\'page\'];
foreach ($screens as $screen) {
add_meta_box(
\'clients\', // Unique ID
__(\'Clients\'), // Box title
$myfunction(\'clients_box_html\'), // Content callback, must be of type callable
$screen, // Post type
\'advanced\', // Context
\'high\' // Priority
);
} } add_action(\'add_meta_boxes\', \'add_clients_metabox\');