0

I've been trying to create a small plugin to do some basic tasks on my website. I created the plugin which was initially working fine, I made no changes and for some reason it no longer works.

Here is the code for my main file:

<?php
/**
 * Plugin Name: Project Keefa
 */

if(!defined('ABSPATH')){die;}

class AdminBMS {

    function register() {
        add_action('admin_enqueue_scripts',array($this,'enqueue'));
        add_action('admin_menu',array($this,'add_admin_pages'));
    }

    function add_admin_pages() {
        add_menu_page('Admin Business Management System','AdminBMS','manage_options','adminbms',array($this,'admin_index'),'dashicons-feedback', 99);
    }

    function admin_index() {
        echo plugin_dir_path( __FILE__) . 'inc/activate.php';
        require_once plugin_dir_path(__FILE__) . 'templates/admin.php';
    }

    function enqueue() {
        wp_enqueue_style('pluginstyle',plugins_url('/assets/style.css',__FILE__),array(''));
        wp_enqueue_script('pluginstyle',plugins_url('/assets/scripts.js',__FILE__),array(''));
    }

}

if (class_exists('AdminBMS')) {
    $adminBMS = new AdminBMS();
    $adminBMS->register();
}

// Activation
require_once plugin_dir_path( __FILE__) . 'inc/activate.php';
register_activation_hook( __FILE__, array( 'AdminBMSActivate', 'activate' ) );

// Deactivation
require_once plugin_dir_path( __FILE__) . 'inc/deactivate.php';
register_deactivation_hook( __FILE__, array( 'AdminBMSDeactivate', 'deactivate' ) );

Activate (inc/activate.php)

<?php 

class AdminBMSActivate {
    public static function activate() {
        flush_rewrite_rules();
    }
}

Deactivate (inc/deactivate.php)

<?php 

class AdminBMSDeactivate {
    public static function deactivate() {
        flush_rewrite_rules();
    }
}

Admin Index (templates/admin.php

<h1>Admin Test</h1>

I am getting the following errors. I've been trying to debug for the past 2 hours, so any help is appreciated! I've tried 644 and 755 permissions on the files too.

Warning: require_once(/home/runcloud/webapps/wordpress/wp-content/plugins/project-keefa/inc/activate.php): failed to open stream: Permission denied in /home/runcloud/webapps/wordpress/wp-content/plugins/project-keefa/project-keefa.php on line 43

Fatal error: require_once(): Failed opening required '/home/runcloud/webapps/wordpress/wp-content/plugins/project-keefa/inc/activate.php' (include_path='.:') in /home/runcloud/webapps/wordpress/wp-content/plugins/project-keefa/project-keefa.php on line 43
  • You have to set same owner of the file activate.php as owner of main plugin file. – KAGG Design May 18 at 17:02

Your Answer

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

Browse other questions tagged or ask your own question.