At your function declaration you need to set the required parameters first, the optional second, because you couldn’t skip $function
if $page
has to be given:
function add_meta_box($id, $title, $page, $function = '', $context="advanced", $priority = 'default'): void
{
require_once(ABSPATH . 'wp-admin/includes/template.php');
add_meta_box($id, $title, array(&$this, $function == '' ? $id : $function), $page, $context, $priority);
}
Or make the $page
variable optional too:
function add_meta_box($id, $title, $function = '', $page = null, $context="advanced", $priority = 'default'): void
{
require_once(ABSPATH . 'wp-admin/includes/template.php');
add_meta_box($id, $title, array(&$this, $function == '' ? $id : $function), $page, $context, $priority);
}
Or make both required:
function add_meta_box($id, $title, $function, $page, $context="advanced", $priority = 'default'): void
{
require_once(ABSPATH . 'wp-admin/includes/template.php');
add_meta_box($id, $title, array(&$this, $function == '' ? $id : $function), $page, $context, $priority);
}