Я пишу плагин WordPress, стиль ООП. Создание таблиц в интерфейсе администратора по-своему требует расширения другого класса.Включая класс в метод другого класса
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
}
}
Просто вызвать метод! Метод «public», поэтому он доступен в подклассе! –
'$ table-> yetAnotherMethod ($ this-> myMethod())'; ?? – Sem
@BenCarey 'AnotherClass' не является производным классом' My_Plugin' –