Wordpress admin notice in plugin function
i have sample wordpress plugin class. Im hooking woocommerce woocommerce_saved_order_items
and i want create a admin notice. Add action from __construct works, but when i want create a notice in hook function it doesnt appears, where is the problem?
class SomeClass {
private static $instance;
public function __construct() {
add_action('woocommerce_saved_order_items',array($this,'orderStatusChange'),10,1);
add_action('admin_notices', array($this,'simple_notice')); // This works
}
public static function getInstance() {
if(!self::$instance)
self::$instance = new SomeClass();
return self::$instance;
}
public function orderStatusChange($orderID){
add_action('admin_notices', 'simple_notice');//This not works
}
function simple_notice(){
?
div class="updated notice is-dismissible"
pThank you for using this plugin! strongYou are awesome/strong./p
/div
?php
}
}
SomeClass::getInstance();