You have two options either define you register methods as static and then you can avoid instantiating your classes or even calling the MyActivation
function ex:
File1.php:
Class File1 {
static function file1_register() {
//register some short codes;
}
static function file1_unregister() {
//unregister previous short codes;
}
}
File2.php:
Class File2 {
static function file2_register() {
//create some database tables.
}
static function file1_unregister() {
//delete previous tables.
}
}
MyPlugin.php:
include_once dirname( __FILE__ ).'/File1.php';
register_activation_hook( __FILE__, array( 'File1', 'file1_register' ) );
include_once dirname( __FILE__ ).'/File2.php';
register_activation_hook( __FILE__, array( 'File2', 'file2_register' ) );
OR simply change the “Paamayim Nekudotayim” (::) to the arrow operator (->) in your current MyActivation
function which means replace this line:
$File1::file1_register();
with this:
$File1->file1_register();