Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Reply To: Plugin Development

Discussion in 'Misc WordPress Requests' started by anurag.deshmukh, Feb 28, 2018.

  1. anurag.deshmukh

    Guest

    Reply To: Plugin Development, by anurag.deshmukh

    You need to pass $this before adding/mentioning the functions. If you are developing plugin with OOP concept, you need to add/use $this else your functions won’t come into action.


    class My_Class_Name
    {

    function __construct()
    {
    if (is_admin()) {
    add_action('admin_menu',array(&$this,'my_class_admin_settings'));
    }
    }

    public function my_class_admin_settings()
    {
    add_menu_page('Page Title','Menu Title','manage_options','my_menu_page',array($this,'my_func_menu_page'),'dashicons-welcome-widgets-menus', 6);
    }

    public function my_func_menu_page()
    {
    // Your functionality goes here
    }
    } // end class

    For the callback name, use this: array($this,'<function name>')

    Reply To: Plugin Development
     
    #1

Share This Page

Monarch Social Sharing Plugin