Using has_filter with a class based plugin to check whether the plugin is active or not

To do literally what you’re wanting here, the easiest way is to store the instance of the plugin class in a global variable at the end of your plugin:

class My_Plugin {
    static $instance;
    function __construct(){} /* or private, with singleton get_instance() method */
    function setup(){ ... }
}
$my_plugin_instance = new My_Plugin();
add_action( 'plugins_loaded', array( $my_plugin_instance, 'setup' ) );

Then you can do:

$has_plugin = (
    isset( $my_plugin_instance ) 
    &&
    has_filter( 'plugins_loaded', array( $my_plugin_instance, 'setup' )
);
if ( $has_plugin ) ...

However, this approach to see if a plugin has been loaded seems overly complicated. Why not just check to see if class_exists( 'My_Plugin' )? If the class does exist, then you know the plugin was loaded. No need to do any checks for if a filter was added.

tech