require_once in class __construct gives “not allowed to access this page”

Developing a plugin.

In the main plugin file, I have:

$class_path = plugin_dir_path(__FILE__) . ‘controller/FW-class.php’;
require_once ( $class_path );

This does not give an error, and everything works at this point. If I echo the path, I get C:xampphtdocstestwp-contentpluginsfw/controller/FW-class.php

In the FW-class.php file I have the class FWplugin, and in that class I have

function __construct(){
$path = “C:xampphtdocstestwp-contentpluginsfw/view/views.class.php”;
require_once( $path );

For the purposes of this question I’ve simply hard coded the path.

The require is being called from plugins/fw/controller/fw-class.php, so it has to go up one folder, and then back down into another folder to find plugins/fw/view/views.class.php

If this same require_once and path is in the main plugin file, no problem. But when called from the function __construct(){ … } it gives Sorry, you are not allowed to access this page.

There are no new entries in the Apache error.log, so I guess it’s not a server error.

Any ideas? The plugin will eventually be available outside of my local installation, so changing WordPress core settings won’t do any good.

Read more here:: require_once in class __construct gives “not allowed to access this page”

Leave a Reply

Your email address will not be published. Required fields are marked *