How to add custom menu item on plugin activation? (1 post)

  1. moroshko
    Posted 3 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic