Support » Plugins » How to add custom menu item on plugin activation?

  • When my plugin is activated, I would like to add a new menu item. Here is my code:

    class My_Plugin {
      function __construct() {
        register_activation_hook(__FILE__, array($this, 'install'));
      function install() {
        add_action('admin_menu', array($this, 'add_menu_item'));
      public function add_menu_item() {
    $my_plugin = new My_Plugin();

    Unfortunately, it doesn’t work. I notice that install is called, but add_menu_item isn’t.

    What would be the proper way to do this?

  • The topic ‘How to add custom menu item on plugin activation?’ is closed to new replies.