Create a static getter for your class instance:
class DD_Awesome_Plugin
{
/**
* Plugin main instance.
*
* @type object
*/
protected static $instance = NULL;
/**
* Access plugin instance. You can create further instances by calling
* the constructor directly.
*
* @wp-hook wp_loaded
* @return object T5_Spam_Block
*/
public static function get_instance()
{
if ( NULL === self::$instance )
self::$instance = new self;
return self::$instance;
}
public function add_menu_page()
{
add_options_page(
'DD Awesome PLugin',
'DD Awesome PLugin',
'administrator',
__FILE__,
array( $this, 'display_options_page' )
);
}
}
And now you get the plugin instance with:
add_action('admin_menu', function() {
DD_Awesome_Plugin::get_instance()->add_menu_page();
});
Or:
add_action(
'admin_menu',
array( DD_Awesome_Plugin::get_instance(), 'add_menu_page' )
);