Closed dac514 closed 6 years ago
WPINC is defined in wp-settings.php and should be called in any standard WP installation.
Besides, this is simply to prevent the file from being called directly.
@afragen
Becauase the plugin is loaded using Composer Autoload, because we use Bedrock, because of the reasons above... WPINC is not always defined.
ABSPATH does the same thing.
You have a number of moving pieces present.
Having a file make use of Composer’s autoloader does not call the file directly, it allows the class to be autoloaded if/when someone calls the class eliminating the need for a require
or include
command.
I confess I no nothing of Bedrock, but I do know that in the usual manner of running WordPress the wp-settings.php
file is called and WPINC is defined.
All this said, I don’t have a strong feeling one way or another and I’ll wait for @collizo4sky to weigh in, but my gut tells me something in Bedrock is loading WP without the wp-settings.php file.
Bedrock might not be standard, but it is best practices for web development IMHO. The issue is that the bootstrapping starts here:
https://github.com/roots/bedrock/blob/master/web/wp-config.php
This plugin, being Composer compatible (2018, yay!), will get initialized by `vendor/autoload.php' before wp-settings.php is called.
Xdebug trace:
Thank you for your consideration.
@afragen I'm going to open an issue on Bedrock. I looked at your plugins. The GitHub one uses this convention as well. From what you say, seems like this convention is common and maybe this is a Bedrock issue. Thanks for the info.
composer update
:wink:
I had this issue in my ProfilePress plugin. I had to fix it by adding this line define( 'WPINC', true );
I just need to update the code to define( 'ABSPATH', true );
because ABSPATH
is not defined in my custom bootstrap process.
Thanks @afragen for the fix for bedrock users
The first 3 lines of this plugin do:
If you look at the WordPress Code you can see that
WPINC
is maybe defined in the 3rd condition. We are setup using https://roots.io/bedrock/ and this plugin is autoloaded using Composer, thereforeWPINC
is never defined anddie
causes a "white screen of death"Please use
ABSPATH
instead.