So I'm learning modern WordPress Development and I'm using classes to organise code etc. I'm having a problem where I'm getting the message: Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'show_message_page' not found or invalid function - Why am I getting this warning when the "Hello" inside the function is working and I can see it on the screen?
I've tried different actions parameters including init.
Here's my code
public function __construct( $plugin ) {
$this->plugin = $plugin;
$this->auth_redirect_uri = get_admin_url( null, 'admin.php?page=clients' );
}
public function init() {
add_action( 'admin_menu', [ $this, 'add_to_admin_menu' ] );
}
public function add_to_admin_menu() {
add_submenu_page(
'clients',
__( 'Messages', 'clientmessage' ),
__( 'Messages', 'clientmessage' ),
'manage_options',
'client_message',
[ $this, 'show_message_page' ]
);
}
public function show_message_page() {
echo "Hello";
}