Requiring a file from another WordPress plugin

I don’t appear to be able to require a PHP file that is part of another plugin.

Let’s say we’re trying to include /wp-content/plugins/plugin-from/src/classes/admin-class.php

Read More

The require_once statements that we’ve tried so far provide a “no such file or directory” error, though declaring a class with the same name as the one included in admin-class.php returns a cannot redeclare class” error.

None of the following methods have produced results:

require_once 'admin-class.php';
require_once '../../plugin-from/src/classes/admin-class.php';
require_once __DIR__ . '/../../plugin-from/src/classes/admin-class.php';

Declaring a global object reference and calling it also returned NULL from var_dump

Once this is working the plan is to instantiate an object of the class in admin-class.php and pass a variable to it.

Related posts

Leave a Reply

1 comment