不要将函数用于回调,请使用类。类似这样:
class Competition_Manager_Page
{
private $extra;
public function set_extra( $value )
{
$this->extra = $value;
}
public function render()
{
// show you page content, then:
print $this->extra;
}
}
以后可以扩展类的功能。
现在,注册菜单时,首先创建该类的实例,然后添加额外数据:
$page = new Competition_Manager_Page;
$page->set_extra( \'Test\' );
add_menu_page(
\'Competition Manager 2013-2014\',
\'2013-2014\',
\'manage_options\',
\'manager_2013_2014\',
array( $page, \'render\' ), // replacement for the former function
plugins_url( \'competition-manager/images/cup.png\' ), 81
);