wp-load.php redeclares classes
I am trying to load WordPress options within a standalone PHP file. The file is located in /wp-content/plugins/plugin-name/file.php
. I have used the following to open wp-load.php:
if (file_exists('../../../wp-load.php')) {
require_once ('../../../wp-load.php');
}
Doing so outputs the following error:
Fatal error: Cannot redeclare some_plugin_function() (previously declared in /var/www/vhosts/domain.com/httpdocs/wp-content/plugins/plugin-name/class-frontend.php:5) in /var/www/vhosts/domain.com/httpdocs/wp-content/plugins/plugin-name/class-frontend.php on line 12
Removing all code from class-frontend.php
does solve the issue, but of course I need that file. class-frontend.php
is not called within the standalone PHP file so am unsure why this is happening.
Topic wp-load.php plugin-development plugins Wordpress
Category Web