plugins - Warning: call_user_func_array() expects parameter 1 to be a valid callback, function

So I'm learning modern WordPress Development and I'm using classes to organise code etc. I'm having a pro

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";
}   

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1741621169a4357014.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信