That global_box_meta_box_callback()
is a class method (i.e. a function inside a class) and not a globally defined function, so you need to use [ $this, 'global_box_meta_box_callback' ]
(or array( $this, 'global_box_meta_box_callback' )
) when supplying the class method to add_meta_box()
:
class Foo
{
...
function wpd_add_meta_box() {
$screens = get_post_types();
foreach ( $screens as $screen ) {
add_meta_box(
'global-notice',
__( 'Global Box 💥', 'global-box' ),
[ $this, 'global_box_meta_box_callback' ], // correct
// 'global_box_meta_box_callback', // incorrect
$screen,
'advanced',
'high'
);
}
}
function global_box_meta_box_callback( $post ) {
// your code here
}
}
See the PHP manual for more details about using/supplying a callable/callback — in your case, we’re using the object method call (see/find // Type 3: Object method call
on that manual).