I'm trying to create the WordPress plug-in using OOP and I got stuck at the beginning. Will be faster if I show code than to describe the problem.
It works:
class Plugin{
public function __construct(){
return;
}
}
function customHeader(){
add_theme_support('custom-header');
}
add_action( 'after_setup_theme', 'customHeader' );
But it doesn't:
class Plugin{
public function __construct(){
if (is_admin()) {
add_action('admin_init', array($this,'admin_init'));
}
}
public function admin_init(){
add_action( 'after_setup_theme', array($this,'customHeader') );
}
public function customHeader(){
add_theme_support('custom-header');
}
}
$plugin=new Plugin();
Do you have any idea why it doesn't work and where there is a mistake ?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire