下面是我的代码。我是插件开发新手。我真的觉得我已经到处寻找解决方案了。很可能这是件愚蠢的事,但我一直在用头撞墙,想弄清楚这是怎么回事。非常感谢您的帮助。非常感谢。
<?php
global $timesheetPluginInit;
$timesheetPluginInit = new TimesheetPluginInit();
class TimesheetPluginInit {
//Calls all init functions
function timesheet_init_plugin() {
$this->timesheet_create_dbs();
$this->timesheet_create_roles();
$this->timesheet_admin_bar_removal();
$this->timesheet_add_plugin_caps();
}
//create database tables
function timesheet_create_dbs() {
//....
}
//creates roles
function timesheet_create_roles(){
//...
}
//kills admin bar
function timesheet_admin_bar_removal(){
//...
}
//adds admin plugin capabilities
function timesheet_add_plugin_caps(){
//...
}
}
register_activation_hook( __FILE__, array( \'TimesheetPluginInit\', \'timesheet_init_plugin\' ) );
对于完整的代码,这里有一个要点:
https://gist.github.com/broskees/69590f9d0baa670bd71b4fb4f6c8b2ba