我正在写一个 WordPress 插件,OOP 风格。以本机方式在管理界面中创建表需要扩展另一个类。
myPlugin.php:
class My_Plugin {
public function myMethod(){
return $somedata;
}
public function anotherMethod(){
require_once('anotherClass.php');
$table = new AnotherClass;
$table->yetAnotherMethod();
}
}
anotherClass.php:
class AnotherClass extends WP_List_Table {
public function yetAnotherMethod(){
// how do I get the returned data $somedata here from the method above?
// is there a way?
// ... more code here ...
// table is printed to the output buffer
}
}