I have used this on my class but it is not working
add_action('admin_init', array($this, 'funname'));
funname function is not calling.function is public.I have refered this url https://wordpress.stackexchange.com/questions/48085/add-action-reference-a-class but still not solved my problem
CODE:
class Test {
public static function Create() {
return $testObj = new Test();
}
public function __construct() {
add_action('admin_init', array($this, 'funname'));
}
public function funname(){
echo "tes2t";exit;
}
}
$ObjTest = Test::Create();
UPDATE:
This code call funname if i put code into theme’s function.php file but not working when put it on plugin file.
UPDATE 2
I have written this line on plugin file directly
add_action( 'admin_init', 'funname' );
function createAdminFromData(){
echo "pre";exit;
}
If i put above code on plugins main file it is working but i have main file of plugin and from that one another file is called where add_action is not working..don’t know why?