add_menu_page not working with in-class function

I’am trying to use add_menu_page to create a custom “custom_post” page. (Is this a mistake already or not ? :-/)

Here’s the code that won’t work :

Read More
add_menu_page( 'projets' , 'projets' , 'edit_posts', 'ajouter_projet' , array( $this, 'afficher_admin_page' ) , $img_url, 5);

But when I use this

add_menu_page( 'projets' , 'projets' , 'edit_posts', 'ajouter_projet' , afficher_admin_page' , $img_url, 5);

with the function afficher_admin_page out of my class, it works.

What am I doing wrong ?

Thank you

Related posts

Leave a Reply

1 comment