The following is my code. I'm new to plugin development. I honestly feel like I've looked everywhere there is to look for a solution. More than likely it's something stupid, but I've been banging my head against the wall trying to figure out what's wrong with this. Any help is greatly appreciated. Thank you!

global $timesheetPluginInit;
$timesheetPluginInit = new TimesheetPluginInit();

class TimesheetPluginInit {

    //Calls all init functions
    function timesheet_init_plugin() {

    //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' ) );

For the full code, here's a gist: https://gist.github.com/broskees/69590f9d0baa670bd71b4fb4f6c8b2ba

1 Answer 1


The register_activation_hook as the first parameter takes:

$file (string) (required) Path to the main plugin file inside the wp-content/plugins directory. A full path will work.

So using __FILE__ for the tag works only when you do it in the main plugin file i.e. plugins/my-super-plugin/my-super-plugin.php.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.