My question is that when we hook to a certain action using the oop way for example
class My_Plugin_Class {
public function __construct( ) {
add_action( 'admin_init', array( &$this, 'some_function' ) );
}
public function some_function() {
//do something here
include( 'some_php_file.php' );
}
}
Then inside that some_php_file.php you included
class Some_Class_Again {
public function __construct( ) {
add_action( 'init', array( &$this, 'another_function' ) );
}
public function another_function() {
//do something here like enqueue script
}
}
is this possible to do? that you hooked a method in your class in an action hook and then inside that method you included another class file making or hooking into another action hook. because when I tried it nothing's happening in the second class. I just want to know if this is possible, if it is am I doing something wrong? or if it's not please tell me why. I have this in mind for quite some time now.
Aucun commentaire:
Enregistrer un commentaire