Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WPINC is not defined. Plugin causes white screen. #14

Closed
dac514 opened this issue Jan 22, 2018 · 9 comments
Closed

WPINC is not defined. Plugin causes white screen. #14

dac514 opened this issue Jan 22, 2018 · 9 comments

Comments

@dac514
Copy link

dac514 commented Jan 22, 2018

The first 3 lines of this plugin do:

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

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, therefore WPINC is never defined and die causes a "white screen of death"

Please use ABSPATH instead.

@afragen
Copy link
Collaborator

afragen commented Jan 22, 2018

WPINC is defined in wp-settings.php and should be called in any standard WP installation.

https://github.com/WordPress/wordpress-develop/blob/8f95800d52c1736d651ae6e259f90ad4a0db2c3f/src/wp-settings.php#L16

Besides, this is simply to prevent the file from being called directly.

@dac514
Copy link
Author

dac514 commented Jan 23, 2018

@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.

@see https://wordpress.stackexchange.com/questions/108418/what-are-the-differences-between-wpinc-and-abspath

@afragen
Copy link
Collaborator

afragen commented Jan 23, 2018

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.

@dac514
Copy link
Author

dac514 commented Jan 23, 2018

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.

@dac514
Copy link
Author

dac514 commented Jan 23, 2018

Xdebug trace:

xdebug-trace

Thank you for your consideration.

@dac514
Copy link
Author

dac514 commented Jan 23, 2018

@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.

@dac514
Copy link
Author

dac514 commented Jan 23, 2018

Related: roots/bedrock#343

@afragen
Copy link
Collaborator

afragen commented Jan 23, 2018

Fixed. 067589b

composer update 😉

@afragen afragen closed this as completed Jan 23, 2018
@w3guy
Copy link
Owner

w3guy commented Jan 23, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants